How to auto populate variables by the use of system property?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a requirement where we need to dynamically show/hide and auto-populate fields in a Record Producer based on selected values.
Scenario:
We have the following variables in a Record Producer:
Category(Select Box)
Subcategory(Select Box)
Subject
Attachment
Requirement:
Based on the selected Category and Subcategory, the Subject and Attachment fields should auto-populate and become mandatory.
If no matching combination is found, these fields should remain hidden.
There are 50+ such combinations, where multiple fields need to auto-populate and toggle mandatory status.
Constraints:
We cannot use UI Policies, as that would require creating 50+ separate UI Policies which would be difficult to maintain.
Looking for a solution using System Properties, Client Script, or other optimized logic to handle this efficiently.
Has anyone worked on a similar requirement? Please suggest the best approach or share any sample implementation.
Thanks in advance for your guidance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
See an use case of System Property (JSON object)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I would use a switch statement in 2 similar onChange Catalog Client Scripts - one that triggers when Category changes, and the other that triggers when Subcategory changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I’ve worked on a very similar requirement where we had to dynamically control field values based on user inputs. Instead of going with multiple UI Policies (which, as you mentioned, becomes difficult to maintain at scale), we used a Decision Table.
In our case, we were passing the country into the decision table and fetching back the region. The logic was called from an onChange client script which further calls script include hitting the Decision Table API and returned the required configuration.
For your scenario, you can follow the same approach:
Maintain your 50+ combinations in a Decision Table (Category + Subcategory as inputs, Subject/Attachment values as outputs).
From the client script on Category/Subcategory change, call the script include to fetch the matching row.
Use the response to auto-populate, show/hide, and set mandatory on the fields dynamically.
This way, your logic stays centralized and easily maintainable; you only update the Decision Table instead of juggling dozens of UI Policies or scattered scripts.
These community article might help you with implementation logic: https://www.servicenow.com/community/developer-blog/servicenow-learning-173-how-to-call-decision-tab...
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you will require 2 onChange catalog client scripts 1 each on category and subcategory.
To store the 50+ combinations I will suggest to store system property and then use GlideAjax to manipulate and then show/hide the options.
what did you start with and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader