GlideRecord LEFT JOIN two tables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 06:42 AM
Hi guys,
How Can I write a LEFT JOIN in ServiceNow?
Exist GlideRecord's method called addJoinQuery for INNER JOIN, but not LEFT JOIN.
Can you help me?
Thanks,
Gaetano
Labels:
- Labels:
-
Scripting and Coding
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2021 10:30 AM
Thanks! I was looking for this too.
For me to make this work with a Database View, I did like the following example:
1. Created a DB View with one View Table without Where Clause: [sys_user]
2. Created before Query business rule:
var join = current.addJoinQuery('ldap_import', 'user_user_name', 'u_samaccountname');
join.addCondition('sys_created_on', 'ON', 'Today@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'); //INNER JOIN
current.addQuery('user_active', 'true'); //ADD where clause to [sys_user]
current.addEncodedQuery("NQuser_user_nameISNOTEMPTY^user_active=true"); //LEFT JOIN