Join 2 table by Glide Record

Khiem
Kilo Contributor

I have two table : user and right, can I join them by GlideRecord : user.right_id = right.right_id ? I see addQuery in GlideRecord have fixed value ex : gr.addQuery('active', 'false').but I want to join 2 table with similar field. pls help me.

4 REPLIES 4

Not applicable

Hi Khiem,

Refer the following link :

https://community.servicenow.com/community?id=community_question&sys_id=2da903e5db5cdbc01dcaf3231f961954

Mark If Helpful

Thanks

Ajay

find_real_file.png

www.dxsherpa.com

Shambhu5
Kilo Guru

Hi Khiem,

Yes in GlideRecord() you can addQuery fixed values. But then your solution also might be that only.

Suppose, you created a Business Rule on User table, there is field right_id. From there, you can GlideRecord() on Right table. You can do something like this to query:

var gr = new GlideRecord('right');
gr.addQuery(gr.right_id, current.right_id);// Or you can right gr.addQuery(gr.right_id,"=",current.right_id)  gr.query();

Please let me know if that worked for you.

Mark my answer as Correct/Helpful if that helps you anyhow.

Regards,
Vishrut
find_real_file.png

Hi Khiem,

Is there any update on your above query?

Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement from the suggestion/input I have provided.

This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

- Vishrut

Khiem
Kilo Contributor

I'm sorry I forgot that.But I want to join two table with condition is table1.field1 = table2.field2 ,not fix condition. Can GlideRecord do that ?