Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to make dependent variable mandatory on basis of choice selected in primary variable.

Puneet4418
Tera Contributor

I have created a record producer and there are two variables X and Y, both referring to sys_choice table and the choices in the variable Y are dependent on variable X choices.

 

Now my requirement is when we select any choices in variable X and if it has any dependent value in variable Y, then make the variable Y mandatory. if there is no dependent value in variable Y it should be non-mandatory. How can I achieve this?

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Puneet4418 

this is trickier.

For this you can use onChange catalog client script on Variable X and see if there is any dependent choice in Variable Y for this value

If yes then make variable Y mandatory

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur Bawiskar
Tera Patron

@Puneet4418 

another way is here to use onSubmit

How set a dependent checkbox variable mandatory which is dependent on another checkbox 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader