Skip to content

Commit f0621dd

Browse files
Create GlideFetchChildRecords.js (#156)
1 parent 729ebd3 commit f0621dd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Description : This macro syntax GlideRecord the specific table to retrieve and process child records from that table
2+
// Modify parent_sys_id, 'table_name',parent_reference_field_name according to your requirement
3+
4+
// code
5+
var parent_sys_id = 'parent_sys_id'; // parent sys_id
6+
var childRecord = new GlideRecord('table_name'); // Glide record the table
7+
childRecord.addQuery('parent_reference_field_name', parent_sys_id); // filter the record according to parent sys_id
8+
childRecord.query(); // query the table
9+
while(childRecord.next()){
10+
gs.info(" Child Record Number " + childRecord.getValue('number')); // child record number
11+
gs.info(" Child Record Short Description " + childRecord.getValue('short_description')); // child record short description
12+
}
13+
14+
// Example
15+
var parent_sys_id = 'a623cdb073a023002728660c4cf6a768'; // parent sys_id
16+
var childRecord = new GlideRecord('incident'); // Glide record the incident table
17+
childRecord.addQuery('parent_incident', parent_sys_id); // filter the record according to parent sys_id
18+
childRecord.query(); // query the table
19+
while(childRecord.next()){
20+
gs.info(" Child Record Number : " + childRecord.getValue('number')); // child incident record number
21+
gs.info(" Child Record Short Description : " + childRecord.getValue('short_description')); // child incident short description
22+
}

0 commit comments

Comments
 (0)