System properties not working in onLoad client script

rmaroti
Tera Contributor

Hi Team,

I need to show some dropdown on the basis of user country  that's why I need to use system properties instead on sys_id of HR service.

 

System properties:

39efd036971111d02698fe7fe153af3c,ff93c2251ba1111046248553604bcb8e,ee1edd771be91550be7f32e2cd4bcb41,f880e836971111d02698fe7fe153af05,ea178f3f1b2d5550be7f32e2cd4bcbf8,79f9e0a01bfa3c9895e6a6c7b04bcb6b,9601bbc81b7de95055c8dd39cd4bcb94,ec6c64bf87617dd0b2a8cae50cbb3527 this are HR service Sys_id which I have pass in value of one of the system properties.

 

Created Display BR-

g_scratchpad.subjectperson_location = current.subject_person.location.country.toString();
g_scratchpad.case_hrservice = gs.getProperty("sn_hr_core.Hr_Service_Generate_Document_Sysid");
 
Client Script -
function onLoad() {
    var location = g_scratchpad.subjectperson_location;
    var hrservice = g_scratchpad.case_hrservice;
    var currentHRService = g_form.getValue('hr_service');
    if (hrservice.indexOf(currentHRService) > -1)
    /*if (hrservice == '39efd036971111d02698fe7fe153af3c' || hrservice == 'ff93c2251ba1111046248553604bcb8e' || hrservice == 'ee1edd771be91550be7f32e2cd4bcb41' || hrservice == 'f880e836971111d02698fe7fe153af05' || hrservice == 'ea178f3f1b2d5550be7f32e2cd4bcbf8') */
    {
        if (location == 'Bahrain' || location == 'Malaysia' || location == 'Philippines' || location == 'United Arab Emirates' || location == 'South Africa' || location == 'Pakistan' || location == 'Indonesia' || location == 'Saudi Arabia' || location == 'Thailand') {
            g_form.addOption('u_generate_documents', 'RL', 'Experience/Reference Letter');
        } else {
            g_form.removeOption('u_generate_documents', 'RL', 'Experience/Reference Letter');
        }
    } else if (hrservice.indexOf(currentHRService) > -1) {
        if (location == 'Malaysia' || location == 'Philippines' || location == 'Pakistan' || location == 'Indonesia' || location == 'Thailand'
            g_form.addOption('u_generate_documents', 'PUL', 'Position Update Letter');
        } else {
            g_form.removeOption('u_generate_documents', 'PUL', 'Position Update Letter');
        }
    }
}
this is client script where always if condition where both condition exicute.
But as per my current record only else if need to be exicute.
 
could you please check it attached screenshot.
in current record screen only position Update Letter need to be visible if HR service is  Create/Update Position
2 REPLIES 2

swathisarang98
Giga Sage
Giga Sage

Hi @rmaroti ,

 

In else if the sytax of removeoption is wrong, you have to add the 

g_form.removeOption('fieldname' 'choicename'); 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Santhosh19
Tera Expert

HI, per my analysis of your code, 

1. how come the if and elseif has same condition "hrservice.indexOf(currentHRService) > -1"

2. you may try declare hrservice  = [];