Hide Related List link on Service Portal

Nen
Tera Guru

Hi. I'm trying to hide the related list link on the Service Portal record

find_real_file.png

I'm on a scoped app and I've tried creating a Client Script but I can't seem to make it work on the portal:

find_real_file.png

I want to hide the related list if the user doesn't have the role needed. The role check is successful since I've been seeing the alert. And when I set the UI Type to Desktop, I saw that the related list was hidden.

The user doesn't have an access to the table so they wouldn't see the records but the Requester wanted to hide the link as well.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

 

this should work, seems like you did not pass the correct table name of related list as well has the second parameter should be true , no quote need to be there. 

 

to  get table name of related list >> go to native ui , open the form>> related list >> right click on column >> list control and then you will see "related list" field , just copy the name and use it in below script.

 

eg: i tested to hide the task sla related list 

 

g_form.hideRelatedList('task_sla.task',true);

View solution in original post

9 REPLIES 9

Hi,

if you want to check for role of logged in user then you cannot use UI policy use client script instead

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

I am using Client Script and I was able to check the role but the related list link is still visible on the portal.

Hi,

any browser console error you are getting on portal?

the below function should work in portal as well; did you set UI type as ALL

g_form.hideRelatedlist('<related list table name'>,true);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Harsh Vardhan
Giga Patron

 

this should work, seems like you did not pass the correct table name of related list as well has the second parameter should be true , no quote need to be there. 

 

to  get table name of related list >> go to native ui , open the form>> related list >> right click on column >> list control and then you will see "related list" field , just copy the name and use it in below script.

 

eg: i tested to hide the task sla related list 

 

g_form.hideRelatedList('task_sla.task',true);

Hi! I might've copied the wrong name of the related list but for some weird reasons, it's working on the platform so I thought it's not just working on the portal.

Anyway, I've tried it again, and I also included the second parameter as you've instructed. It's now working fine (both for the platform and on the portal). Thank you so much!