How to Clear all variables in a catalog item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 03:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 03:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 03:32 AM
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 03:34 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 03:34 AM
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]
****************************************************************************************************************