Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Prevent non-admin users from modifying, adding, or removing columns in the Default list view layout

Chinmay_P
Tera Contributor

Hello,

We have a requirement to prevent non-administrator users from adding or removing columns in the default list layout across all tables.
We attempted to address this using Before Business Rules on the sys_ui_list and sys_ui_list_element tables.
Business Rule 1 (on sys ui list)

  • Filter Conditions: View is Default view
  • Applied on : Insert , Update , Delete
  • Condition: !gs.hasRole('admin')
  • Script: Aborts the action and displays an error message.

Business Rule 2 (on sys ui list element)

  • Filter Conditions: List ID.view is Default view
  • Applied on : Insert , Update , Delete
  • Condition: !gs.hasRole('admin')
  • Script: Aborts the action and displays an error message.

During testing, we found that while the default list layout successfully restricts users from adding new columns via Configure > List Layout, the system concurrently deletes all other existing fields from the default view.
Does any one work on the same / any idea for this ?

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Chinmay_P 

default list layout can only be configured by users with personalize_list role

why this requirement?

I will recommend not to play with system tables such as those involved for views, lists etc

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Chinmay_P
Tera Contributor

Hello @Ankur Bawiskar ,
Thank you for your response.

We observe that removing the personalize_list role successfully prevents users from seeing the Configure > List Layout option.

However, the specific requirement from the client is to ensure that the only default list view layout is uneditable for all non-administrator users across the platform.
Do we have any alternate solution for this requirement ?

@Chinmay_P 

share scripts from both the business rules

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

Chinmay_P
Tera Contributor

Hello @Ankur Bawiskar ,
We have used below script in Business Rule

Business Rule 1 (on sys ui list)

  • Filter Conditions: View is Default view
  • Applied on : Insert , Update , Delete
  • Condition: !gs.hasRole('admin')
  • Script:

(function executeRule(current, previous /null when async/ ) {

        gs.addErrorMessage(
'You are not allowed to modify the Default View layout.');
        current.setAbortAction(
true);

})(current, previous);


Business Rule 2 (on sys ui list element)

  • Filter Conditions: List ID.view is Default view
  • Applied on : Insert , Update , Delete
  • Condition: !gs.hasRole('admin')
  • Script: 

(function executeRule(current, previous /null when async/ ) {

        gs.addErrorMessage('You are not allowed to modify the Default View layout.');
        current.setAbortAction(true);

})(current, previous);