How to Clear all variables in a catalog item

Bijay Kumar Sha
Giga Guru

Hi,

I've 4 variable sets and many variables in those variable sets. All the variables are be shown/hidden/mandatory depending upon the selection criteria.

How I can clear all the values on the catalog form, when I change my selection from one to another. 

Currently, when I'm selecting any variable required fields are getting showed up and I'm filling the values, but when I'm changing, it's keeping all the values. 

I've tried to write a script in the UI policy itself as g_form.clearValue('field_name'); but it's not working. 

 

I just want to reset all the field values once I toggle between different variables or choice values in a variable. 

5 REPLIES 5

Ehab Pilloor
Mega Sage

Hi @Bijay Kumar Sha,

You have the option to set or clear variable value in UI Policy action. Use set type so that reverse if false clears the value in those variables.

 

If you found my response helpful, please mark it as Solution and Helpful.

 

Thanks and Regards,

Ehab

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Bijay Kumar Sha 

 

Did you try the Cleared option in UI Policy?

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

So you don't actually want to clear all values right? Since you do want to keep the value of the field you are toggling?

 

If a lot of fields are already on UI Policies, just make use of Clear the Variable/Field value. If that's not the case, I can imagine the you don't want to setup a new UI Policy with potentially a ton of UI Policy Actions (and that requires possible maintenance every time a variable is changed/added). I need to look If I got something for that, to handle all Variables except one or two scripted so no future maintenance required.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Dr Atul G- LNG
Tera Patron
Tera Patron

AGLearnNGrow_0-1725014073898.png

 

 

@Bijay Kumar Sha 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************