How to hide the Post Incident Review Related list based on Role?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello Everybody,
I want to hide the related list "Post Incident Review" in incident form based on a role "major_incident_manager'.
So only Major Incident Managers can only see the tab in both UI and in the Service Operations Workspace.
I can't see the Related list name to write a OnLoad Client Script with the sys_id, can someone help me on this?
UI Backend:
Workspace:
This is OOTB behavior but we want to customize it so that only Major Incident Managers can see those tabs in both UI and workspace? please help me on this
Thanks in Advance!
Thanks,
Sattar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
For native you can show/hide section using onLoad client script using g_form.hideRelatedList()
For native
- Go to any 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)
- g_form.showRelatedList('Related_list_value');
The above won't work for workspace as that function is not supported
function onLoad() {
if (!g_user.hasRole('major_incident_manager')) {
g_form.showRelatedList('Related_list_value');
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
29m ago
Hi @Ankur Bawiskar thanks for your reply.
All the Incident Post Reviews are stored in "sn_sow_inc_post_incident_review.incident_ref" table.
I tried the same as you mentioned, there is no existing List control available.
I created it but it didn't work, please check the below screenshots and correct me if anything is wrong?
List Control- Related List Name: sn_sow_inc_post_incident_review.incident_ref
Client Script:
Thanks,
Sattar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
23m ago
you are using wrong script
You should hide it when role is not your role
function onLoad() {
if (!g_user.hasRole('major_incident_manager')) {
g_form.showRelatedList('sn_sow_inc_post_incident_review.incident_ref');
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13m ago
@Ankur Bawiskar it is also not working.
I impersonated a user who don't have major incident role but he can see the related list.
Thanks,
Sattar