- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi everyone,
I’m working on a form that has a choice field with 4 different options. Each option should display a different set of fields. To achieve this, I created 4 separate UI Policies, one for each option.
However, I’m running into a problem:
Some fields are included in more than one UI Policy Action
When I change the option, the fields from the previous UI Policy remain visible
Even if I disable Reverse if false, the issue continues
It looks like the UI Policies are overriding each other and not resetting the form correctly
My question: What is the correct way to handle this scenario when the same field appears in multiple UI Policies? Should each field only be controlled by a single UI Policy, and if so, what is the recommended structure for 4-option logic?
Any guidance or best practices would be greatly appreciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
Hi @beycos,
You can achieve this by using a catalog client script; this approach will be easier than using UI policies for number conditions. Below is the script you can use; just put your field values in the script properly.
Let me know if this works!!!!😉
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
switch(newValue) {
case 'option1':
showFields(['field1','field2']);
break;
case 'option2':
showFields(['field2','field3']);
break;
case 'option3':
showFields(['field4']);
break;
case 'option4':
showFields(['field1','field5']);
break;
}
}
If you find my answer useful, please mark it as Helpful and Correct. 😊
Regards,
Soham Tipnis
ServiceNow Developer || Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
better to go with 1 onChange client script instead of 4 UI policies
You can control the show/hide easily in that script
Please start with this and let us know
💡 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
3 hours ago
Hi @beycos
I can see that you have created duplicated posts. Please see my response here: https://www.servicenow.com/community/developer-forum/ui-policy-is-not-working/m-p/3510250#M1250848
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Please refer this links:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
Hi @beycos,
You can achieve this by using a catalog client script; this approach will be easier than using UI policies for number conditions. Below is the script you can use; just put your field values in the script properly.
Let me know if this works!!!!😉
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
switch(newValue) {
case 'option1':
showFields(['field1','field2']);
break;
case 'option2':
showFields(['field2','field3']);
break;
case 'option3':
showFields(['field4']);
break;
case 'option4':
showFields(['field1','field5']);
break;
}
}
If you find my answer useful, please mark it as Helpful and Correct. 😊
Regards,
Soham Tipnis
ServiceNow Developer || Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
better to go with 1 onChange client script instead of 4 UI policies
You can control the show/hide easily in that script
Please start with this and let us know
💡 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
3 hours ago
Hi @beycos
I can see that you have created duplicated posts. Please see my response here: https://www.servicenow.com/community/developer-forum/ui-policy-is-not-working/m-p/3510250#M1250848
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
