ui polices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
51m ago
Title
UI Policies not working to show/hide fields based on Request Type in ServiceNow form
Description
Hi everyone,
I'm developing a custom Access Request form in ServiceNow where fields should be displayed based on the selected Request Type.
My requirement is:
- Add Role → Show Select Role and Source User
- Add Multiple Roles to User → Show Select Multiple Roles and Source User
- Add Multiple Roles to Multiple Users → Show Select Multiple Roles and Select Multiple Users
- Add Group → Show Select Group and Source User
- Add Multiple Users to Single Group → Show Select Group and Select Multiple Users
- Add Multiple Users to Multiple Groups → Show Select Multiple Groups and Select Multiple Users
- Copy Access → Show Source User and Target User
Initially, all these fields should be hidden.
I created separate UI Policies for each Request Type condition to show/hide the required fields, but the UI Policies are not working as expected. The fields remain visible (or do not change) when I select a different Request Type.
I also tried implementing the same logic using an onChange Client Script, and although the script executes and newValue is correct, the fields still do not show/hide.
Environment
- Custom table
- Request Type is a Choice field with values 0–6
- Using the Next Experience form (see attached screenshots)
My questions
- Do UI Policies support dynamic field visibility in the Next Experience form?
- Is there any limitation with g_form.setDisplay() or UI Policies in this UI?
- Should I use Client Scripts, UI Policies, Workspace Client Scripts, or another approach to implement this requirement?
- Has anyone implemented similar dynamic field visibility in the Next Experience form?
I've attached screenshots of my form and the expected behavior.
Any suggestions would be greatly appreciated. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43m ago
share script here instead of script screenshot
what debugging did you do?
Did the onChange run?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22m ago
Hi @vodnalar26
You will need to create 7 distinct policies (one for each Request Type rule)
- Navigate to Service Catalog > Catalog UI Policies > click New.
- Ensure Reverse if false is checked.
- Fill out the specific mappings via the Catalog UI Policy Actions related list:
UI Policy Condition (request_type is...) |
Actions: Set Visible to True | Actions: Set Visible to False (Handled by Reverse if False) |
Add Role | select_role, source_user | All other variables |
Add Multiple Roles to User | select_multiple_roles, source_user | All other variables |
Add Multiple Roles to Multiple Users | select_multiple_roles, select_multiple_users | All other variables |
Add Group | select_group, source_user | All other variables |
Add Multiple Users to Single Group | select_group, select_multiple_users | All other variables |
Add Multiple Users to Multiple Groups | select_multiple_groups, select_multiple_users | All other variables |
Copy Access | source_user, target_user | All other variables |
Alternative, You can achieve it using single onChange catalog Client script ( field is Request Type)
Other visibility -you can control using script ( if coding is fine for you)
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19m ago
Hello @vodnalar26 ,
I'd recommend pick one approach only, deleting the client script and using 7 declarative UI Policies instead, one per Request Type value, each explicitly setting Visible/Mandatory true for the two relevant fields and false for the other five.
If my response help mark as helpful and accept the solution.