Cant hide a particular related list in workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 10:28 PM - edited 03-17-2025 11:15 PM
I have to hide related lists to certain users. one of the related list is only visible on configure > related list, but not on form. Created a client script, it hid all the related lists on form , however it is not hiding the one that is not shown on form in Workspace.
This one is of relationship type and is added on selected realted lists but not visible on the form. However I can see the related list name (REL:xxxxxx) when printing logs in Client script. checked for any existing Client scripts , UI policies, Didn't find any.
g_form.hideRelatedLists(g_form.getRelatedListNames());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 11:39 PM
if that field is true and if no records are there then it will hide list header
try removing true from it and see
Does your current record have related records in related list?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-18-2025 12:28 AM
Set "omit empty condition" to true , Now related list is visible but no longer hidden on both form and workspace . Few of the other related lists are relationships too , this one seems to be the only causing issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:55 AM
share the complete script.
Since it's a defined related list this logic will work
g_form.hideRelatedList('REL:e1c005f91b0c2a508e08fc451a4bcbd2');
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-18-2025 01:14 AM - edited 03-18-2025 01:14 AM
Approach 1:
var listNames = g_form.getRelatedListNames();
for (var i = 0; i < listNames.length; i++) {
g_form.addInfoMessage(g_form.hideRelatedList(listNames[i]));
g_form.hideRelatedList(listNames[i]);
}
Approach 2:
g_form.hideRelatedLists(g_form.getRelatedListNames());
Approach 3:
var listNames = g_form.getRelatedListNames();
for (var i = 0; i < listNames.length; i++) {
g_form.addInfoMessage(g_form.hideRelatedList(listNames[i]));
g_form.hideRelatedList(listNames[i]);
}
g_form.hideRelatedList('REL:595d5cad3b720010d901655593efc479');
Tried all 3 approaches seperately
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 01:37 AM
Approach 1 and 2 won't work.
Approach 3 should work as you have a defined related list.
share your client script is applicable to any view?
Try using this in native form view and see if it gets hidden
Ctrl+shift+alt+J -> Javascript Executor
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader