Comments on: Leveraging Joins in GlideRecord Queries https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/ ServiceNow Consulting Scripting Administration Development Sat, 03 Aug 2024 14:46:29 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Achim https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/#comment-10090 Sat, 03 Aug 2024 14:46:29 +0000 https://servicenowguru.com/?p=16590#comment-10090 In reply to Jacob Kimball.

Absolutely correct, the Related List Query allows multiple conditions to be applied on the related / “joined” table. Still, the “join” can only be done on the sys_id field on the base table, so only tables can be used as related / “joined” table which will have a field containing the sys_id of the base record.
I would thereby also assume that the performance is quite similar to JOIN Query.

]]>
By: Jacob Kimball https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/#comment-10089 Fri, 02 Aug 2024 13:29:25 +0000 https://servicenowguru.com/?p=16590#comment-10089 In reply to Achim.

Achim, I don’t really have any insight around performance implications between the two approaches….in fact, I had never seen the Related List Query syntax for encoded queries before. Thanks for pointing that out! One thing that does hit me as a difference is that the RLQUERY approach seems to allow for multiple filters to be applied on the ‘joined’ table. The ‘JOIN’ approach did only allow 1 filtering attribute. I’m guessing that the performance is fairly similar between the two as I’m guessing they are both essentially sub queries.

]]>
By: Achim https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/#comment-10088 Fri, 02 Aug 2024 07:55:11 +0000 https://servicenowguru.com/?p=16590#comment-10088 Thanks for sharing!

Do you also have insights into any (performance) implications for scenarios in which also a Related List Query can be used similar to JOIN Query?

In the given example of this blog article this could be:

var query = “active=false^RLQUERYincident.problem_id,>=1^active=true^ENDRLQUERY”
var ProbGr = new GlideRecord(‘problem’);
ProbGr.addEncodedQuery(query);
ProbGr.query();

Would be interesting to know if there are any advantages or disadvantages of choosing one possible solution over the other.

]]>
By: Jacob Kimball https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/#comment-10087 Thu, 01 Aug 2024 20:47:12 +0000 https://servicenowguru.com/?p=16590#comment-10087 In reply to Sam Goode.

Sam, Excellent! I noticed the same in the doc as well…after the article was written. Might be worth a “part 2” and some point. Thanks for linking the doc in!

]]>
By: Sam Goode https://servicenowguru.com/scripting/leveraging-joins-gliderecord-queries/#comment-10086 Thu, 01 Aug 2024 20:31:18 +0000 https://servicenowguru.com/?p=16590#comment-10086 Great find, I will be using this! It looks like addJoinQuery takes some additional optional arguments to control the fields to join on (primaryField from the initial GlideRecord, which would likely be sys_id in most cases, and JoinTableField for the field on the table you are doing the subquery that references the record you are filtering)
https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/glideRecordScoped/concept/c_GlideRecordScopedAPI.html#r_ScopedGlideRecordAddJoinQuery_String_Object_Object

]]>