- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 02:33 AM
Hi Everyone,
I have Three Tables A,B and C. Table B has a field referring to Table A , and Table C has a field referring to Table B. Now I want the list of Matching Records from Table C as a Related List in Table A. I have created a Relationship Record bw Table A and Table C,but I am having a hard time querying the Matching records in Table C.
How can I do it ?
Please pour Your Thoughts.Thanks in Advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 04:26 AM
something like this
Applies to Table - Table A
Queries from Table - Table C
Script:
var tableBArr = [];
var gr = new GlideRecord("table B");
gr.addQuery("fieldReferringToTableA", parent.sys_id);
gr.query();
while (gr.next()) {
tableBArr.push(gr.getUniqueValue());
}
current.addQuery('fieldReferringToTableB.sys_id', 'IN', tableBArr.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 04:26 AM
something like this
Applies to Table - Table A
Queries from Table - Table C
Script:
var tableBArr = [];
var gr = new GlideRecord("table B");
gr.addQuery("fieldReferringToTableA", parent.sys_id);
gr.query();
while (gr.next()) {
tableBArr.push(gr.getUniqueValue());
}
current.addQuery('fieldReferringToTableB.sys_id', 'IN', tableBArr.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader