Catalog Item Variable Depedency Issue (Fields Disabled/Visible Inconsistently)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi All,
I am working on a catalog item in ServiceNow and facing an issue with variable behavior.
In my catalog item:
- I have a variable "Request Type" with 4 choices.
- Based on the selected Request Type, another variable "Request Reason" is shown.
- The "Request Reason" field contains 8 choices.
- Further, based on the selected Request Reason, some related fields get populated and displayed.
Issue:
- When I change the Request Type, some dependent fields:
- Become disabled, or
- Sometimes remain visible, and
- Sometimes behave inconsistently (enabled/disabled/visible).
What I Tried:
- Verified UI Policies and Client Scripts
- Checked variable dependencies
Question:
- Why are the dependent fields behaving inconsistently (visible vs disabled)?
- Is there any best practice to manage such multi-level dependencies?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
hey @anushinde05
This behavior typically happens due to overlapping control on the same variables, especially when both UI Policies and Client Scripts are involved.
Root Cause
In multi-level dependencies like:
Request Type - Request Reason - Dependent Fields
the issue is usually:
- Child variables are not reset when the parent changes
- Previous UI Policy states remain applied
- Multiple sources (UI Policy + Client Script) are trying to control the same field
This results in:
- Fields staying visible when they should hide
- Fields becoming read-only unexpectedly
- Inconsistent behavior on change
Approach
1 . Reset child variables on parent change
Create an onChange Client Script on Request Type:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
// Reset child variable
g_form.setValue('request_reason', '');
// Reset all dependent fields
var fields = ['field_1', 'field_2'];
fields.forEach(function(field) {
g_form.setDisplay(field, false);
g_form.setReadOnly(field, false);
g_form.clearValue(field);
});
}
2 Use clear responsibility
- UI Policies - control Visible / Mandatory
- Client Scripts - handle reset and flow control
Avoid both controlling the same property.
3 . Ensure “Reverse if false” is checked
Without this, fields retain their previous state when conditions change.
4. Keep dependency flow strict
Request Type - controls Request Reason
Request Reason - controls dependent fields
Avoid controlling deep-level fields directly from Request Type.
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @vaishali231,
Thanks for your response.
In our case, we have created UI Policies based on Request Reason in ServiceNow.
If Request Reason = Network, network-related variables are displayed
If Request Reason = Software, software-related variables are displayed
However, the issue is:
When we switch from Network → Software → back to Network,
some of the network-related variables are not showing again
It seems like previous UI Policy states are not getting reset properly.
Could you please suggest how to handle this scenario so that fields always display correctly when switching values?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
since you have multiple levels of dependencies you need to make sure the relevant UI policy on Request Reason triggers well and does it's job based on change of Request Type
what debugging did you do?
share your findings.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Thanks for your response.
In our case, we have created UI Policies based on Request Reason in ServiceNow.
- If Request Reason = Network, network-related variables are displayed
- If Request Reason = Software, software-related variables are displayed
However, the issue is:
When we switch from Network → Software → back to Network,
some of the network-related variables are not showing again
It seems like previous UI Policy states are not getting reset properly.
Could you please suggest how to handle this scenario so that fields always display correctly when switching values?
Thanks!
