How to make a field mandatory based on a choice selected from a variable set

Jesus Nava
Tera Guru

Hello Experts, I have a variable set type Add Row with a variable called "Service" which is a list collector.

find_real_file.png

what i need is that if a user selects "Other" from the list collector, a field that is not in the variable set called "Additional Comments" turns mandatory. I have done this with 2 regular  fields using a UI policy but not for a variable set, can you guide me on how to proceed?

find_real_file.png

Thank you

 

1 ACCEPTED SOLUTION

@Jesus Nava, May Bad!

yes, you are right in that case please revert it back to the variable set. In the run script's Execute if true field use setMandatory syntax like this.

g_form.setMandatory('variables.additional_comments', true);

Execute if false field write below

g_form.setMandatory('variables.additional_comments', false);

Regards,

Muhammad

Regards,
Muhammad

View solution in original post

11 REPLIES 11

Sagar Pagar
Tera Patron

Hi @Jesus Nava,

You have to create Catalog UI Policy or Catalog Client script on Catalog item.

Use the variable (variable set) in Condition builder and make the required field mandatory using UI Policy action.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Hello Sagar,

Thank you I tried it like that using the following:

find_real_file.png

In the UI actions I just saw the fields from the variable set, the field I need mandatory is outside the Vset, I tried this:

find_real_file.png

and no luck, 

Regards

Hey, as Sagar mentioned, please change the Applies to field value from variable set to catalog item. Then create UI policy actions to make other fields mandatory. 

 

Regards,
Muhammad

Thank you, I did it like that:

find_real_file.png

but in the conditions I don't see the variable set, I just see the regular variables I created for the item, this is my issue, how to get the additional field mandatory when a choice from a vset is selected,

Thank you

@Jesus Nava, May Bad!

yes, you are right in that case please revert it back to the variable set. In the run script's Execute if true field use setMandatory syntax like this.

g_form.setMandatory('variables.additional_comments', true);

Execute if false field write below

g_form.setMandatory('variables.additional_comments', false);

Regards,

Muhammad

Regards,
Muhammad