onChange Client Script needs to run on Catalog Task

cre1014
Kilo Expert

Hello everyone!

 

We got a very intricate request for a new item for our service catalog, and I'm having some trouble setting it up.

 

With this catalog item, the initial request is submitted with half of the numerical data that's needed. Once it reaches the first catalog task, it must be populated with the rest of the numerical data and then calculations need to be made with that data. But it has to do all of this on the catalog task form, NOT the catalog item. I'm trying to create an onChange client script to run on the Catalog Task table so the script runs in the right situation, but it's not recognizing what I need to be doing. I know that onChange scripts often need a field/variable attached to them so Service Now can see when it's going to fire the script, which is fine. However, the field that I need the script to fire on is a variable from the catalog item, not a field on the catalog task form itself.

 

Is there any way to achieve this?

1 ACCEPTED SOLUTION

Hi



You can use catalog client scripts on RITM/TASK also.



you just need to modify the form layout of catalog client script and add 'applies to RITM/ applies to TASK'



and then by checking one of these you can set it to run on the task or RITM form.



Lemme knw if you need more


View solution in original post

6 REPLIES 6

akt_snow
Giga Expert

You can choose the variable instead of the field. it would give you that option.


The ability to choose the variable in question is only possible through the Catalog Client Scripts (which, to my understanding, only run on catalog items). I need to run this onChange script on the Catalog Task table; the only options that exist in the drop down are fields that are related to the Catalog Task table, not the catalog item.



screen.png



I've tried the "Variables" selection as shown in the screenshot, but to no avail. I'm really looking to see if this is even possible before I waste time trying to get it coded.


Hi Caitlyn, I think you can do something like this using an onload client script that will attach an onchange javascript event to the variable you want to monitor, and then creating a script that will run with the onchange event.



The variable has the same ID always because it will bring an answer that is hosted in a different table, so, using chrome or firefox you can right click the variable and select the inspect element option and copy the id of the variable input, and use this id with DOM to attach a new event to it.



Does it sounds familiar to you? Let me know if you need any additional info.


Hi



You can use catalog client scripts on RITM/TASK also.



you just need to modify the form layout of catalog client script and add 'applies to RITM/ applies to TASK'



and then by checking one of these you can set it to run on the task or RITM form.



Lemme knw if you need more