- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2020 09:15 PM
Hi. I'm trying to hide the related list link on the Service Portal record
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:
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.
Solved! Go to Solution.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 09:44 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2020 01:29 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 07:41 PM
I am using Client Script and I was able to check the role but the related list link is still visible on the portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 08:46 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 09:44 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2020 12:35 AM
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!