Cant hide a particular related list in workspace

Kumar38
Kilo Sage

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());

 

 

22 REPLIES 22

@Kumar38 

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?

AnkurBawiskar_0-1742279937745.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

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.

@Kumar38 

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.

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

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

@Kumar38 

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

AnkurBawiskar_0-1742287025833.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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