New and Edit UI Action Visibility on Related List

Anubhav24
Mega Sage
Mega Sage

Hi All,

For the catalog tasks related list on sc_req_item , I want to show New button based on role, I have created a new role and when I am trying with a user which is non-admin the New button is visible if the user has the specific role and if the user does not have specific role the New button is not visible but if a user is admin the button is visible always even though the admin user does not have that role.

Note : The Omit new button is unchecked and Omit New condition is empty , I am just trying with roles assigned.

Any leads on this would be appreciated.

Please see attached screenshot:

AnubhavSrivas2_0-1677053484361.png

@Ankur Bawiskar @SatyakiBose 

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Anubhav24 

admin user gets all the roles so you should not test with admin user

Anyhow in production there won't be admin users who will be working on the RITM or SC TASKs

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

Hi ,

Thanks a lot for your reply , so as I understand if the button is made visible admin user would be able to see it if the visibility is controlled through roles (Can you please confirm this).

@Anubhav24 

with roles you cannot control since admin gets all roles.

The use case of testing with admin user is invalid as no admins will be using the application once it gets into production.

They are just involved in admin activities etc

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

SatyakiBose
Mega Sage

Hello @Anubhav24 

You need to add the 'admin' role condition in the UI Action as well, in addition to the list control.

This is the UI action that is invoked for the new button on the catalog tasks related list.

https://xxxxx.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=7b37cc370a0a0b34005bd7d7c7255583

You can try the below and see how it works.

  1. Create a new UI action similar to the one above, but set the table as sc_task.
  2. Make sure the new one overrides the above OOB UI Action.
  3. In the new UI action set a condition that current user does not have admin role. Your condition should have this: gs.hasRole('omit_new_button_role') && !gs.hasRole('admin')

Because of this OOB UI action condition, the admin user is able to see the New button.