How to Make a Variable Non-Mandatory?

Himesh Murthy
Tera Contributor

Hello,

I have a Catalog item that is using a Variable set containing two variables

1) Requested By - Mandatory on Variable Level

2) Justification - Mandatory on Variable Level

I have to make these two variables non mandatory on one of the catalog item. Please let me know if there's a way (method) to achieve this using onLoad Client Script. Thanks in advance!

 

Regards,

Himesh

1 ACCEPTED SOLUTION

Basically if the Variable is mandatory on the Variable level itself through the checkbox, then you can't make it not mandatory through UI Policy or Client Script. You simply can't. So you need to follow my approach if you want to achieve this.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You would need to change the variables in the Variable Set and set them to NOT mandatory. Then with a UI Policy (why Client Script?!) you can make the Variable mandatory for that particular Catalog Item by adding a UI Policy in the Catalog Item itself and adding a UI Policy Action to set the Variable to mandatory=true.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hello @Mark Roethof,

 

Thanks for the quick response!

I cannot afford to make it non mandatory on the field/variable level as they're being used in Several other catalog items. Can we not override a Mandatory variable on the field level using UI policy or any other methods?

Basically if the Variable is mandatory on the Variable level itself through the checkbox, then you can't make it not mandatory through UI Policy or Client Script. You simply can't. So you need to follow my approach if you want to achieve this.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Aman Kumar S
Kilo Patron

Hey,

You have to make the fields non mandatory, and set them mandatory using UI policy in your variable set.

Then create one UI policy on your catalog item and have higher order

Best Regards
Aman Kumar