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.

How to disable list edit by role

dwilborn
Tera Contributor

Hey All,

A quick search didn't turn up anything recent so I wanted to confirm.

The only way to restrict list editing, per table, by role, is to create a list_edit ACL type correct?

We can't leverage the simple drop down because we want admins and "power users" to be able to utilize the list view to make changes.

find_real_file.png

If there is an easy way or something I'm over looking I'd love to hear about it before escalating to senior admins to modify ACLs.

Thanks,

Daniel

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Hi Daniel, 

 

Obviously ACL is best when it comes to security but to restrict cell edit based on role you can use on-cell edit client script. 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
  var saveAndClose = false;
  var isOK = g_user.hasRoleFromList("admin, power_user"); //replace with comma separated list of required roles 
  
  if(isOk){ 
    
      saveAndClose = true;
  } 
 
 callback(saveAndClose); 
}

 

Please mark this accepted & helpful if it answered your question.

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

View solution in original post

2 REPLIES 2

MrMuhammad
Giga Sage

Hi Daniel, 

 

Obviously ACL is best when it comes to security but to restrict cell edit based on role you can use on-cell edit client script. 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
  var saveAndClose = false;
  var isOK = g_user.hasRoleFromList("admin, power_user"); //replace with comma separated list of required roles 
  
  if(isOk){ 
    
      saveAndClose = true;
  } 
 
 callback(saveAndClose); 
}

 

Please mark this accepted & helpful if it answered your question.

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

DrewW
Mega Sage

 

I would use an ACL for this.  You will have easier control and can set this for the whole table if needed.  onCellEdit is one field at a time.