Not able to hide related list using g_form.hideRelatedList / hideRelatedLists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:03 AM
Hi Team,
I have 4 related lists on my page , and i want to hide/show 2 of these under certain conditions.
I have tried the following but nothing seems to work for one of the related list
g_form.hideRelatedList('REL:sys_id');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:05 AM - edited 12-23-2024 06:06 AM
Can you show what related list is hidden and what is not? And what script have to tried?
Screenshot of related list and script you have tried
whichj one of it worked on second one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:20 AM - edited 12-23-2024 06:26 AM
L1 : Penetration Test Findings
L4 : Penetration Test Findings NPT
The 2nd one is UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:30 AM
Hi @Anubhuti Mittal ,
Create UI Policy with condition and create "UI policy related list action" instead of writing code.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:05 AM - edited 12-23-2024 10:08 AM
Hi @Anubhuti Mittal ,
Instead of passing just the sys_id of the defined relationship, you will also need to prepend it with the following string 'REL:'
The syntax will be as follows:
g_form.hideRelatedList('REL:sys_id');
g_form.hideRelatedList('REL:70e80f390a0a0b1b0035a51d8bbfd32c');
Go to System Definition > Relationships and search for the table relationship associated with your related list name .
Example screenshots:
Navigate as below System UI -> Related Lists
In script screenshots which you pasted that will hide form sections not related lists, if you want to hide related use above approach with correct relationship names.
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand