Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to join between two tables in now-sdk?

anthonydian
Tera Contributor

Hello now-sdk community,

 

I'm having some troubles making joinQuery to work in a now-sdk Typescript script.

 

For a specific need, I need to be able to make a join between two tables (with a 0-n relationship).

I'm able to achieve that without issue using a background script, this way

var firstGr = new GlideRecord('firstTable');
var secondGr = woGr.addJoinQuery('secondTable');
firstGr.addQuery('u_field', 'filteredValue');
secondGr.addCondition('u_second', 'anotherValue');
secondGr.addCondition('u_third', 'aThirdValue');
firstGr.query();

while(firstGr.next()) {
	gs.info(firstGr.u_field);
}

 

But, when I try to write this code in my now-sdk Typescript based project (using @Servicenow/glide dependency on version 26.0.1), this code is not recognized by my IDE (the "secondGr.addCondition" doesn't seem to exist).
After some research, it seems that the typing provided with now-sdk glide dependency does not reflect the actual signature.

The Xanadu documentation tells us that the addJoinQuery instruction is returning a GlideQueryCondition object, but in the now-sdk lib, this is a IQueryCondition that is returned (and this interface has no members).

 

Has anyone ever managed to make join queries to work in a now-sdk project using Typescript?

 

Thanks for your time!

Anthony

1 ACCEPTED SOLUTION

BryceG
ServiceNow Employee
ServiceNow Employee

Sorry about this, we will log a bug to get this fixed in a future version.  For now you might just have to use //@ts-ignore above those calls to surpress the error.

View solution in original post

2 REPLIES 2

BryceG
ServiceNow Employee
ServiceNow Employee

Sorry about this, we will log a bug to get this fixed in a future version.  For now you might just have to use //@ts-ignore above those calls to surpress the error.

anthonydian
Tera Contributor

Hello @BryceG , thanks a lot for a quick reply.

That's what we did waiting for your answer 🙂