The CreatorCon Call for Content is officially open! Get started here.

Amit Gujarathi
Giga Sage
Giga Sage

Hi All,

I hope you are doing fine.

  • In this tutorial, we will be looking over one more interesting method in the ServiceNow magic world i.e. GlideRecord addJOinQuery() method.

  • So what exactly does this addJoinQuerymethod do?

  •  
  • From the name don’t confuse it with the actual database join, instead, it just adds the subquery so that the result set will be confined to the subquery which you have defined.

  • Let's look at the inputs and outputs of the method

    • Input :
      • table — String — Table name
      • primary field — String —If other than sys_id, the primary field.
      • joinTableField — String — If other than sys_id, the field that joins the tables
    • Output :
      • GlideQueryConditionRecords — where the relationships match.
  • Example :

    var now_GR = new GlideRecord('problem'); 
    now_GR.addJoinQuery('incident', 'opened_by', 'caller_id'); 
    now_GR.query();
    
  • You can set the glide.invalid_query.returns_no_rows system property to true to have queries with invalid encoded queries return no records.

Agenda :

  • Introduction to addJoinQuery method

  • Understanding the problem statement

  • Understanding the Usecase for the same

  • Demo

  • Note: Always thoroughly test the addJoinQuery() method in the sub-prod instance before putting it to prod as the wrong structure may lead to a huge mess.

 

Please be sure to bookmark this article as well as mark it as Helpful if you thought it was helpful.

Regards,

Amit Gujarathi

Technomonk Youtube: https://www.youtube.com/c/TechnoMonkAmit

Amit Gujarathi Linkedin: https://www.linkedin.com/in/amit-gujarathi-98632a175/

TheTechnomonk.com : https://thetechnomonk.com/

ServiceNow Community Amit Gujarathi: https://www.servicenow.com/community/user/viewprofilepage/user-id/265565

GitHub: https://github.com/amigujarathi

Version history
Last update:
‎12-01-2022 01:04 AM
Updated by:
Contributors