Catalog client script to display field if location is US

Simran321
Tera Expert

Hi There,

 

I want to write the onLoad() client script that displays the variable "extend_date) if Location.country is 'US'. 

 

I do not have subject person field available on Catalog form. Subject person is availble on Parent case Subject person. How do I query the parent case to get the user value?

 

function onLoad() {
   //Type appropriate comment here, and begin script below
var user = new GlideRecord ("sn_hr_le_case");
//add code
   
 
var ga = new GlideAjax('HRServiceutil');
    ga.addParam('sysparm_name', 'getLocation');
    ga.addParam('sysparm_user', user);
    ga.getXMLAnswer(callback);
    function callback(response) {
 
        // alert('coming inside the response' + typeof response + " -  " + response);
 
        if (response == 'United States of America' || response == 'USA') {
           // alert('coming inside the response1' + typeof response + " -  " + response);
 
            g_form.setMandatory('do_you_want_to_extend_this_employee_s_travel_dates', true);
            g_form.setDisplay('do_you_want_to_extend_this_employee_s_travel_dates', true);
           
        } else  {
           // alert('coming inside the response2' + typeof response + " -  " + response);
           
g_form.setMandatory('do_you_want_to_extend_this_employee_s_travel_dates', false);
g_form.setDisplay('do_you_want_to_extend_this_employee_s_travel_dates', false);
            
    
 
}
}
 
}
1 REPLY 1

Mohammed Al-Mar
Tera Guru

Hi @Simran321 your question is not clear for me, but If you are looking for details in the parent you may need script like this:

function onLoad() {
   var caseGR = new GlideRecord('sn_hr_le_case');
    caseGR.get(g_form.getUniqueValue());

    // Check if the case has a parent case
    if (caseGR.parent && caseGR.parent.case_parent) {
        var parentCaseGR = new GlideRecord('sn_hr_le_case');

        if (parentCaseGR.get(caseGR.case_parent)) { 
            var subjectPerson = parentCaseGR.subject_person;
           //continue your code