- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 07:27 AM
Hi,
I have Table1 (Primary) and Table2 (Secondary), I need to fetch both tables fields using addJoinQuery() with GlideRecord(), Please suggest what is the other way work around in Server Script?
Thanks
Arul
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 07:30 AM
Hi,
try going below links for help
Regards
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
‎11-27-2020 07:30 AM
Hi,
try going below links for help
Regards
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
‎11-27-2020 08:27 AM
Additionally you can also add related list condition via addEncodedQuery 😉
Example when querying for active problems where there is at least on related incident of priority 1:
var gr = new GlideRecord("problem");
gr.addEncodedQuery("active=true^RLQUERYincident.problem_id,>=1^priority=1^ENDRLQUERY");
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 09:04 AM
Thanks for marking my response as helpful.
Did my reply answer your question?
If so, please mark it correct so that the question will appear as resolved for others who may have a similar question in the future.
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
‎11-29-2020 02:39 AM
Well, GlideRecord does not really allow you to do real joins. What you can do is for example find records where a reference has a certain value, but you cannot directly read the data of the refereced table (unless you use getReferenceRecord).
To perform proper joins as you would expect them in a decent database, create a view and join the tables there:
Database views | ServiceNow Docs
Best
Daniel
If this post was helpful, I would appreciate if you marked it as such - thanks!
Best
Daniel