How to display records in a related list based on a condition ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 07:01 AM
Hi All,
I have created a relationship between incident and problem. This will give the list of the problems with the same CI and that has atleast 1 major incident attached.
This relationship has been added to the related list of the Incident form.
Now my requirement is that, I have major incident (checkbox) on the incident form. Only when this checkbox is selected, the records in the related list should be displayed. If it is unchecked, the records should remain hidden.
How do i go about doing this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 07:06 AM
Hi Ritesh,
So you can use this. show the related list if checkbox is true; hide the related list if checkbox is false
function onLoad(){
var value = g_form.getValue('major_incident');
if(value.toString() == 'false')
g_form.hideRelatedList('nameofrelatedlist');
}
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
‎08-01-2019 07:12 AM
Ankur has beaten me to this but i'll just add, if it's a relationship the name will REL:sys_id eg:
g_form.hideRelatedList('REL:aee27790374ff70044fe03a973990eaa');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 07:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2019 02:42 AM
Hi Ankur,
g_form.hideRelatedList('nameofrelatedlist');
This hides the related list. But what I require is that the related list should stay, but only the records should get displayed when the major incident checkbox is checked.