Catalog Client Script Not Working Correctly Against RITM

jmiskey
Kilo Sage

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:

find_real_file.png

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:

find_real_file.png

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:

find_real_file.png

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

 

 

7 REPLIES 7

sachin_namjoshi
Kilo Patron
Kilo Patron

This method is not supported by Service Catalog.

You can see confirmation from below 

 

setLabelOf

 

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.

find_real_file.png

 

 

Regards,

Sachin

Would I need to run this Client Script against the Catalog Item table, the Requested Item table, or both?

it will be for both.

 

Regards,

Sachin

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