- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 05:18 AM
Hi ,
I Want to get Related Child Records of a Record .
Explanation :
I have a Record , which is Parent to Multiple Records of Another Table .
Two Tables " Table " and " Column"
" Table " has 1 Record .
" Column " has 5 Records .( These 5 Records are Child of " Table " Record 1 via Reference Field .
shown Below : Column Record named "ACTIVE " Is child of "Table " Record Customer ,
Now ,
I want to get all the Child Records By Giving " TABLE " Record "sysId"
Here i dont have Child Table Name .
I have Parent Table name , Parent Record sysid
i need Parent Record's Child Records
Kindly help me with the code ,
Thankyou ,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 06:04 AM
child.addQuery('sys_id', 'sys_id of parent record ');
child.query();
if(child.next())
{
var child1 = new GlideRecord('<related list table name>');
child1.addQuery('<Column which make the relation >',child.sys_id);
child1.query();
while(child1.next())
{
gs.info(child1.name);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 05:25 AM
Hi there,
you can get it easily
var child = new GlideRecord('<'name of column table'>');
child.addQuery(<back end value of table field>,'sys id you have');
child.query();
while(child.next())
{
gs.print(child.name);
}
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 05:32 AM
Hi Thanks ,
Here i dont have Child Table Name .
I have Parent Table name , Parent Record sysid
i need Parent Record's Child Records
can you help me with this .
Thanks ,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 06:04 AM
child.addQuery('sys_id', 'sys_id of parent record ');
child.query();
if(child.next())
{
var child1 = new GlideRecord('<related list table name>');
child1.addQuery('<Column which make the relation >',child.sys_id);
child1.query();
while(child1.next())
{
gs.info(child1.name);
}
}