Catalog UI Policy

muskaanchan
Tera Contributor

I ma tryint 

I am working on a ServiceNow Catalog Item where I have multiple UI Policies to show/hide variables based on a choice field called “Modification Type”.

🔹 Modification Type values:

  • Item/Category Approval Matrix Modification → approval_matrix_modification
  • Item Form Modification → form_modification
  • Item/Category Visibility Modification → visibility_modification

🟦 Issue:

I have created Catalog UI Policies with conditions like:

  • modification_type = approval_matrix_modification
  • modification_type = form_modification
  • modification_type = visibility_modification

Each UI Policy is configured with:

  • On Load = true
  • Reverse if false = true
  • UI Policy Actions to show/hide variables accordingly

Problem:

On form load, all variables are visible instead of being hidden.

Even after selecting a specific Modification Type, unrelated variables are still visible or not hiding properly.


🟦 What I have already tried:

  • Verified UI Policy conditions
  • Checked choice values (label vs value mapping)
  • Set UI Policy Actions for visible/mandatory correctly
  • Adjusted UI Policy order
  • Ensured variables are not mandatory by default

Still, UI Policies are not behaving as expected.


🟦 Question:

What is the correct approach to ensure that:

  • All variables are hidden on load by default
  • Only relevant variables appear based on selected Modification Type
  • UI Policies correctly evaluate choice values (label vs actual value)

 

8 REPLIES 8

Tanushree Maiti
Tera Patron

Hi @muskaanchan 

 

What is your requirement  or expected output?

 

ref: https://www.youtube.com/watch?v=MdKPSlt4mK8

https://www.youtube.com/watch?v=a6ta2qBA7Go

https://www.youtube.com/watch?v=BgwB3k8qIMg

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
ServiceNow | how to create catalog UI policy | catalog ui policy #servicenow #sandiego #servicecatalog
In this ServiceNow Tutorial, Technical Consultant Laurence Tindall gives a demo on Catalog UI Policies in ServiceNow. UI policies can be used to define custom process flows for tasks. Catalog UI policies control the behavior of catalog item forms when presented to your users. Catalog UI policies ...
Catalog UI policies are used to control the behavior of the fields displayed in catalog item form. It executes on the client side. However we can write script in catalog UI policies, but it provide us the flexibility that without writing script we can make fields or Variables ready only ...

Hi 

The requirement is to dynamically show and hide catalog variables based on the selected value of the Modification Type field.

Expected output is that only the relevant set of variables should be visible (and mandatory where required) depending on the selected modification type, and all other unrelated variables should remain hidden on the catalog item form.

 
 
 

Ankur Bawiskar
Tera Patron

@muskaanchan 

I will suggest creating 1 onChange catalog client script instead of 3 catalog UI policies

Handle the onLoad and onChange in that

Easy to maintain

function onChange(control, oldValue, newValue, isLoading) {
    toggleModificationTypeFields();
}

function toggleModificationTypeFields() {
    var type = g_form.getValue('modification_type');

    var approvalVars = [
        'approval_group',
        'approval_level',
        'approver_user'
    ];

    var formVars = [
        'field_name',
        'field_label',
        'field_type'
    ];

    var visibilityVars = [
        'catalog_name',
        'category_name',
        'visible_to',
        'hidden_from'
    ];

    var allVars = approvalVars.concat(formVars, visibilityVars);

    for (var i = 0; i < allVars.length; i++) {
        g_form.setDisplay(allVars[i], false);
        g_form.setMandatory(allVars[i], false);
        g_form.setValue(allVars[i], '');
    }

    if (type == 'approval_matrix_modification') {
        showFields(approvalVars);
    } else if (type == 'form_modification') {
        showFields(formVars);
    } else if (type == 'visibility_modification') {
        showFields(visibilityVars);
    }
}

function showFields(fields) {
    for (var i = 0; i < fields.length; i++) {
        g_form.setDisplay(fields[i], true);
    }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi,
I understand but the requirement is to do this using catalog ui policies only