Catalog client script order when Catalog item has both catalog Item level catalog client script and variable set level catalog client scripts

Haritha Marathi
Tera Contributor

Hi,

I have a catalog Item in which i have used a common variable set which has on load catalog client script at variable set level (Which auto populates the default value for "Requested For"). I have created a on load catalog client script at catalog item level to make "Requested For" as blank, However it is getting over ride by the catalog client script at variable set level. I have tried by changing the order of the catalog client scripts still it's not working

Thanks in advance

1 ACCEPTED SOLUTION

Hi Harita,



You did not required 2 scripts for that. So your maintaining variable auto population in variable set, in that only you can add this line of code



if (g_form.getUniqueValue() == 'your catalog item sys_id'){// means you don not need to set the values of item


g_form.setValue('first_name','');


g_form.setValue('last_name','');


g_form.setValue('company','');


}


else{


your existing code to populate the records.


}



Try this way and you can delete or inactive the script on catalog item level.


View solution in original post

3 REPLIES 3

BALAJI40
Mega Sage

Can i know what is the requirement exactly.


First variable set script will execute and then item level scripts will execute in servicenow.


You can use "default value" concept, instead of going with script, like placing of javascript:gs.getUserID()


For "Requested For" default value we are using,   javascript:gs.getUserID(). Based on this value we are populateing variables like First Name, Last name, Company of the user. That script was common and it was running at Variable Set Level. For this particular Catalog Item I want to blank out the details of the user (First Name, Last name, Company of the user), this script was written at Catalog Item Level


Hi Harita,



You did not required 2 scripts for that. So your maintaining variable auto population in variable set, in that only you can add this line of code



if (g_form.getUniqueValue() == 'your catalog item sys_id'){// means you don not need to set the values of item


g_form.setValue('first_name','');


g_form.setValue('last_name','');


g_form.setValue('company','');


}


else{


your existing code to populate the records.


}



Try this way and you can delete or inactive the script on catalog item level.