Catalog Client Script Not Working Correctly Against RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 06:21 AM
We have come across some great code that we use in a Catalog Client Script in a Catalog Item that allows us to change the label of a variable in the Catalog Item based on the entries from other variables in the same Catalog Item.
The Catalog Client Script looks like this:
So based on the value selected in the "Request Type" field, it determines which label to use for the "Name" field.
It works perfectly on the Catalog Item on the Service Portal. An example looks like this:
You can see, as "New SharePoint site" is selected as the Request type, it shows the "Please provide the name of the SharePoint site you would like to be created:" in the label of the next field.
So it works great on the Catalog Item on the Service Portal. However, even though the Catalog Client Script has the "Applies on Requested Items" check box checked, it does not seem to work when viewing the submitted request from within ServiceNow. If I bring up the Requested Item in ServiceNow, this is what I see in the Variables section:
As you can see, the description erroneously says "Please provide the name of the team you would like created" instead of the "Please provide the name of the SharePoint site you would like to be created:" text.
Why is this not being to the RITM from within ServiceNow?
Does it have someting to do with it being in the "Variables" section?
How can I get this to work properly?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 08:39 AM
This method is not supported by Service Catalog.
You can see confirmation from below
In your case, use below approach to set label dynamically
variableSysID = 'variable sys_Id';
gel('label_IO:' + variableSysID).childNodes[0].childNodes[1].innerHTML = 'My new Label Text Here';
Note : Make sure you Unchecked ISOLATED SCRIPT Checkbox. If its not available on the form then add it to form and do it or you can uncheck it from list view as well.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 11:04 AM
Would I need to run this Client Script against the Catalog Item table, the Requested Item table, or both?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 11:20 AM
it will be for both.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 11:31 AM
Additionally, I think you want to display updated label on form load but your script is running on onchange hence it will not work onload.
I believe you have to create new onload script specifically on RITM and Catalog TASK and add the script