The CreatorCon Call for Content is officially open! Get started here.

UI policy Script to show/hide related list based on user roles

Michael Galang
Tera Contributor

Hi Experts, 

 

Good day! 

I just want to ask your expert opinion on how to control show/hide of related list using UI policy. 

I created  UI policy that should control the show/hide of Related List name (task_sla.task) using below conditions and 

MichaelGalang_0-1711503781396.png

 

with the g_user that will check the user role based on below specific roles 

MichaelGalang_1-1711503965780.png

 
However, when I impersonate a user that doesn't have the required roles the realated list (task_sla.task) still showing. 

I would appreciate any help help regarding this matter. 

Thanks in advance.  



1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @Michael Galang you dont need to pass sysid under hasRole. You need to use like below

Refer documentation: https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/client/c_GlideUserAPI#r_GlideUs...

var isItil = g_user.hasRole('itil');

 

Regards
Harish

View solution in original post

5 REPLIES 5

Sohail Khilji
Kilo Patron

Hi @Michael Galang 

 

  • Instead of Parent_Table_Name We have to use the ‘Related list’ field value from the list control

Try to Log a message to see if your conditions are met !

 

Go to the  form where the related list is present.

 

Right-click to open the column context menu on the related list.

Select Configure > List control.

 

the ‘Related list’ field value from the list control. (Suppose - "Related_list_value" is the value)

Now the statement should be g_form.showRelatedList('Related_list_value');

 

I hope this helps...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi Sohail, 

 

Thank you for your help. It works now. 😀

Harish KM
Kilo Patron
Kilo Patron

Hi @Michael Galang you dont need to pass sysid under hasRole. You need to use like below

Refer documentation: https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/client/c_GlideUserAPI#r_GlideUs...

var isItil = g_user.hasRole('itil');

 

Regards
Harish

Hi Harish, 

It works now. Thank you for your help.