Catalog Client Script not working on Employee center with g_form add and clear options

Josh Evans
Tera Contributor

Hello,

 

I am having and issue with a Catalog Client Script in the Employee Center that is not populating a choice list with options as it is in the normal Service Catalog. I have set the Client Script UI Type to all as you can see in the screenshot I have provided. 

 

JoshEvans_0-1701845796674.png

As I said, it works exactly as expected in the normal Catalog, but in the Employee Center, the drop down just has None. 

 

Any help would be appreciated.

 

Thanks,

Josh

 

6 REPLIES 6

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Josh Evans ,

 

can we try putting some alerts at the beginning n after the if condition to check if the script is even being called.

 

Thanks,

Danish

 

Hello Danish,

 

Thank you for your response, I added alerts at the start of the script and inside the If condition, and the script is being called just fine, but not getting into the if condition only on the Employee Center.

 

Thanks,

Josh

DanielCordick
Mega Patron
Mega Patron

Can you paste in your script. Hard to see on the screenshot

function onChange(control, oldValue, newValue, isLoading) {
   alert("Called Script");
    var getReason = g_form.getValue('variables.reason_for_leaving');
    if (getReason == 'Resignation') {
        alert("in if statement");
            g_form.clearOptions('variables.specific_reason');
            g_form.addOption('variables.specific_reason', '', '');
            g_form.addOption('variables.specific_reason', 'Dissatisfied with Culture', 'Dissatisfied with Culture');      
            g_form.addOption('variables.specific_reason', 'Relocation', 'Relocation');    
            g_form.addOption('variables.specific_reason', 'Dissatisfied w/ Career Opportunities', 'Dissatisfied w/ Career Opportunities');    
            g_form.addOption('variables.specific_reason', 'Dissatisfied w/ Type of Work', 'Dissatisfied w/ Type of Work');
            g_form.addOption('variables.specific_reason', 'Dissatisfied w/ Supervisor', 'Dissatisfied w/ Supervisor');
            g_form.addOption('variables.specific_reason', 'Dissatisfied w/ Pay', 'Dissatisfied w/ Pay');
            g_form.addOption('variables.specific_reason', 'No Call No Show/ Job Abandonment', 'No Call No Show/ Job Abandonment');
            g_form.addOption('variables.specific_reason', 'Lack of Job Stability', 'Lack of Job Stability');
            g_form.addOption('variables.specific_reason', 'Personal/ Family Circumstances', 'Personal/ Family Circumstances');
           
        } else if (getReason == 'dismissal') {
            g_form.clearOptions('variables.specific_reason');
            g_form.addOption('variables.specific_reason', '', '');
            g_form.addOption('variables.specific_reason', 'Retirement', 'Retirement');
            g_form.addOption('variables.specific_reason', 'Death', 'Death');
            g_form.addOption('variables.specific_reason', 'Mutual Consent', 'Mutual Consent');
            g_form.addOption('variables.specific_reason', 'Transfer to Affiliate', 'Transfer to Affiliate');
            g_form.addOption('variables.specific_reason', 'Unsatisfactory performance', 'Unsatisfactory performance');
            g_form.addOption('variables.specific_reason', 'Staff Reduction/RIF/Redundancy ', 'Staff Reduction/RIF/Redundancy ');
            g_form.addOption('variables.specific_reason', 'Misconduct', 'Misconduct');
            g_form.addOption('variables.specific_reason', 'Failure to Return from Leave ', 'Failure to Return from Leave ');
            g_form.addOption('variables.specific_reason', 'Boarded – Did not start', 'Boarded – Did not start');
            g_form.addOption('variables.specific_reason', 'End of Fixed Term Arrangement', 'End of Fixed Term Arrangement');
        } else {
            g_form.clearOptions('variables.specific_reason');
        }


}