The CreatorCon Call for Content is officially open! Get started here.

How to auto populate variables by the use of system property?

Vishal_Jaiswal
Tera Expert

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:

  1. Category(Select Box)

  2. Subcategory(Select Box)

  3. Subject

  4. 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!

@Ankur Bawiskar 

5 REPLIES 5

Rafael Batistot
Kilo Patron

Brad Bowman
Kilo Patron
Kilo Patron

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.

M Iftikhar
Giga Sage

@Vishal_Jaiswal ,

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.

 

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@Vishal_Jaiswal 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader