Can we GlideRecord parent table through child table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 09:56 AM
Hii all,
just for curiosity I want to know can we GlideRecord a Parent table through child table. Suppose I create GlideRecord object on incident table and fetch Task table data. Is it possible?
var gr = new GlideRecord('incident')
gr.addQuery('parent field') //which is on task field
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 10:02 AM
Hi Siddharam,
Yes, we can do that. So actually parent table contains the child table records as well so the sys_id of the incident can be fetched in the task table because as I mentioned above parent table holds the same record.
All the fields on the parent table also extended to the child table so yes you can query directly.
If you can share the real scenario then maybe I can help you with the script.
Regards,
Muhammad
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 10:10 AM
I have scenario where I want to populate a Case form priority on a Task table when state changes on sales table which inherit a Case table and Case table inherits Task table. Task -> Case -> Sales.
I have to write a BR on Case table, when state changes on a Sales Table I have to map priority of sales with Task.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 10:21 AM
Ok as the sales table is the grand child of the task table so task table contains the record it self so your script would be something similar to below. You can adjust it for your needs.
BR should be on the Sales table because you are checking for state change on sales table.
Condition: State changes
Script
var grTask = new GlideRecord("task");
if(grTask.get(current.getValue("sys_id"))){
grTask.priority = current.priority; //update the name of priority field if different
grTask.update();
}
Above script will take priority of sales table and update on the task table.
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2022 12:49 AM
Just wanted to check if the above answered your question. If so, please close the thread by marking the answer as correct to help future users.
Regards,
Muhammad
Muhammad