Setting a Catalog Task variable to mandatory based on the value of another

Wayne Richmond
Tera Guru

Hi all. I've been reading some of the many discussions on Catalog Task variables in order to resolve my issue but haven't found anything definitive. Here's what I'm trying to achieve:

On a Catalog Task I have two variables 'sdr_replace_success' and 'sdr_issues'. sdr_replace_success is a Yes/No field with None. If the selection is 'no' I want to make sdr_issues mandatory. To do this I've been trying to use a UI Policy with Scripts enabled. Here is what I've ended up with with no success:


task1.png

task2.png

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

I think you are creating this as a "normal" UI Policy on the Task form, correct?   I would create it as a Catalog UI Policy instead and check the "Applies to Catalog Tasks" field:


____Jim_C_____.png



You may have to switch to the the "Advanced" view to see the field.   And then you can use a "Catalog UI Policy Action" to set the variable to mandatory instead of with a script.


View solution in original post

9 REPLIES 9

marcguy
ServiceNow Employee
ServiceNow Employee

I know when doing this in a catalog ui policy or catalog client script (which incidentally you can tick to run on items and task forms too).



then you just need to use g_form.setMandatory('variable_name'), not variables.variable_name.


Thanks but that didn't seem to work


He's doing it on the catalog task itself and not on the variable/item level so he needs to use "variables.variable_name" in this case.


Jim Coyne
Kilo Patron

I think you are creating this as a "normal" UI Policy on the Task form, correct?   I would create it as a Catalog UI Policy instead and check the "Applies to Catalog Tasks" field:


____Jim_C_____.png



You may have to switch to the the "Advanced" view to see the field.   And then you can use a "Catalog UI Policy Action" to set the variable to mandatory instead of with a script.