- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 06:39 PM
Hello,
I haven't created catalog items in a while. My question is, what is the best way to show/hide variables based off of a selection from a drop down?
I have 10 fields on the item. The first field is a selection with 2 choices. If they select choice 1, it will show the other 9 fields. If I select choice 2, only 7 of the 9 fields will display. What is the best of writing this in a catalog client script?
thanks!
Solved! Go to Solution.
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 10:06 PM
Just want to add to this, don't forget to clear the variable values. For example when filling out the form, a user can decide to change variables which cause other variable not to be visible anymore... though those variables will still contain it's contents!
So do use the "Clear the variable value" option, or add scripting to empty the variable. This is an often missed step I see at customers.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2021 07:15 AM
You have 2 options to do it->
1. Via UI policy- you need to know all the conditions and frame UI policy accordingly.
2. Via Client Script- You can use client script to check for every value using g_form.getValue(parent) and show a field via g_form.setVisible(variablename,true);
You can write a function in client script which can reduce lines of Code.
Confusions can be cleared