Glide Record add join Query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2019 11:16 AM
Guys i am working on scripted api anyone has idea about how to access column of user table using join
var gr = new GlideRecord('cmdb_ci_service');
gr.addJoinQuery('sys_user', 'company',gr.company);
gr.query();
while(gr.next()){
//i want to access user table columns like email,name,mobile phone
gs.print(gr.user_name);
}
Unable to access user table .In scripted api multiple glide is slowing the response so the only solution is addjoin query in scripted api.
Note:Databaseview is not an option for this purpose
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2019 01:44 PM
Hello,
Per documentation, it looks like you may be using it incorrectly: https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideRecord-AddJoinQuery_String
Example here:
// Look for Problem records
var gr = new GlideRecord('problem');
// That have associated Incident records
var grSQ = gr.addJoinQuery('incident');
// Where the Problem records are "active=false"
gr.addQuery('active', 'false');
// And the Incident records are "active=true"
grSQ.addCondition('active', 'true');
// Query
gr.query();
// Iterate and print results
while (gr.next()) {
gs.print(gr.getValue('number'));
}
So you'd "join" in the table as an additional query parameter, but then use other addQuery or AddCondition entries to narrow in on your target.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!