How to modify the visibility of a related list UI action?

Linda6
Mega Guru

Dear all,

how/where do I get to modify the visibility of a related list UI action? I did not find it anywhere.

Namely I would like to restrict users to add/remove groups of other users, if they are not the manager of that given group and at the same time they must have the 'itil' or 'itil_admin' role. 

I tried to do this through ACLs, but it does not function as expected.

So thought of a workaround of hiding the New/Edit related list UI actions if the signed in user does not fulfill the above mentioned criteria.

I mean these UI actions:

uiactionrelatedlist.png

6 REPLIES 6

Abhijit4
Mega Sage

Right click on related list column as shown below :

Right click->confgire->List Control

 

Abhijit4_0-1669380985008.png

You can check omit new/edit button on form

Abhijit4_2-1669381062465.png

 

Please mark answer as Correct or Helpful based on impact.

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Thank you @Abhijit4 ,

however I need to omit it only for those users, that do NOT have the 'itil' or 'itil_admin' role && are not the manager of the given group that is being added or removed from that user..

My code apparently doesn't work, can you please help me out a bit with it...?

Omit edit and omit new conditions shall be the same:

 

var answer = false; //restrict access by default
if(gs.hasRoleFromList('itil','itil_admin') && current.group.manager.sys_id == gs.getUserID()) {
	answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}

Method 'hasRoleFromList' works for g_user object. 

 

Instead please try below,

 

var answer = false; //restrict access by default
if((gs.hasRoleExactly('itil') || gs.hasRoleExactly('itil_admin')) && current.group.manager.sys_id == gs.getUserID()) {
	answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}

 

if you want to check is user either has role or he is manager then you might need to add OR operator in between as below:

 

var answer = false; //restrict access by default
if(gs.hasRoleExactly('itil') || gs.hasRoleExactly('itil_admin') || current.group.manager.sys_id == gs.getUserID()) {
	answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}

 

Please mark answer as Correct or Helpful based on impact.

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Hi @Abhijit4 

it blocks me out, even if me as an admin cannot see those New/Edit UI actions...

Any suggestions how to do this some other way? Is there any other way than omitting or using ACLs (those did not work in my case)