Do UI policies work on list view?

Mouktik_B
Tera Contributor

The UI policies work when the incident is opened , but on list view it does not . How to fix the issue?

5 REPLIES 5

AndersBGS
Tera Patron
Tera Patron

In ServiceNow, UI Policies typically work on individual form records rather than on list views. However, if you want to control the display of certain fields or make them read-only within a list view, you can use Client Scripts or UI Actions. Here's how you can achieve this:

 

Using Client Scripts for List View:

  1. Create a Client Script: Go to "System Definition" > "Client Scripts" and create a new Client Script.

  2. Configure the Client Script:

    • Table: Choose the table for which you want to apply the UI behavior in the list view.

    • Type: List

    • Script: Write JavaScript code to control the field behavior. For example, to make a field read-only:

 

 

function onLoad() {
    g_list.getColumns().forEach(function(column) {
        if (column.getName() === "your_field_name") {
            column.setDisplay("true");
        }
    });
}

 

 

Replace "your_field_name" with the actual name of the field you want to control.

 

Save the Client Script.

 

Refresh the List View: After creating and saving the Client Script, refresh the list view where you want this behavior to apply.

This Client Script will control the display and behavior of the specified field in the list view.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

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/

Hi @Mouktik_B 

 

If my answer has helped with your question, please mark my answer as accepted solution.

 

Best regards

Anders

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/

Eswar Chappa
Mega Sage
Mega Sage

Hi @Mouktik_B ,

UI Policies have 2 types - onload and onchange. Hence it will not working in list view.

Client script have 4 types - onload, onchange, oncell edit, onsubmit. you can write on cell edit client script for your business requirements.

 

You can review below community article for reference:

https://www.servicenow.com/community/developer-forum/why-ui-policy-does-not-work-on-list-view/m-p/15...

 

Thanks & Regards,

Eswar Chappa

Mark my answer correct and Helpful if this helps you ðŸ˜€

OlaN
Giga Sage
Giga Sage

Hi,

UI Policies only work on the form, if you want the same behavior in the list you can instead use a Data policy.

These evaluate on server side, so manipulating records in list view will also follow these policies.

(and if you like, the same behavior can be applied on data imports and integrations)

 

Do note that a data policy will also prevent you from scripting and setting values that is invalid according to the created data policy.