Hide the Delete button from core_company table.

ServiceNowSteve
Giga Guru

Good Afternoon All,

Today we has a user acidently delete a company record from our core_company table and as a result I am trying to hide the Delete button (Not use an ACL to restrict) and despite my searching all I can find as a solution is to use the UI Policy to make it visible to noly users with admin roles which is fine but when I add gs.hasRole("admin") to the global Delete condition it does nothing for the ITIL users.

Anyway the one way I did get the delete button to disappear was a client script that used.

var items = $$('BUTTON').each(function(item)

  {

              if(item.innerHTML.indexOf('Delete') > -1)

{

                      item.hide();

              }

      });

but that also deleted it from the Admin role....so I guess I need a little guidance on how to hide the option from only ITIL users and not Admin users on a specific table.

1 ACCEPTED SOLUTION

adamjgreenberg
ServiceNow Employee
ServiceNow Employee

ACL's are the best way to hide items from specific groups of users.



As you found out, javascript can hide such an item, but it is global in nature.


View solution in original post

10 REPLIES 10

adamjgreenberg
ServiceNow Employee
ServiceNow Employee

ACL's are the best way to hide items from specific groups of users.



As you found out, javascript can hide such an item, but it is global in nature.


Blaze2
Kilo Guru

You are going to have to use the ACL and add the appropriate role that you want to allow who has the access to delete a record.



I have a policy that only the admin can remove something after a change request has been submitted. Once the Change is approved, I get a task and delete.


vinothkumar
Tera Guru

Best way to do is the with the help of delete ACL and it is not advisable to do with Javascript.


ServiceNowSteve
Giga Guru

Thanks for the feedback. Typically I'd agree that an ACL is the way to go but there's a secondary issue at play here.



In our environment we allow users to make new user records and associate them with our company table (so that we know what user works at what location) and the Delete ACL for the core_company table allows users with a user_admin role to delete company tables. Our ITIL users need that role to make users but we still need them to not delete tables.



I'm afraid if I pull user_admin from the company table it will cause an issue and that's why I want to just hide the button.