- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 01:56 PM
Hi all,
How do I add an "and" condition to the BR user query?
I would like to filter in assigned_to not only inactive users, but also other users who have a certain attribute in their user profile, such as "on leave" (u_on_leave), which is a true/false field.
current.addActiveQuery().addCondition('u_on_leave', false);
seems to make the user with u_on_leave=true vanish from all lists, including from the list of users in sys_user...
Thanks,
Harel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 02:23 PM
Hi Harel,
You may also find below link helpful for reference.
Controlling record access using 'Before Query' business rules - ServiceNow Guru

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 02:19 PM
Yes, it is working as expected. In your business rule you have coded that it should only show all active users and who has u_on_leave false. So when ever you query on the sys_user table, this br will be triggered, like reference fields on sys_user table, lists

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 02:23 PM
Hi Harel,
You may also find below link helpful for reference.
Controlling record access using 'Before Query' business rules - ServiceNow Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 04:16 PM
Thank you Pradeep and mark.stanger (of-course) - the link helped. The script looks like this (I am not filtering out inactive users):
if (gs.getSession().isInteractive()) {
current.addQuery('u_on_leave', false);
} //Modify the current query on the assigned_to field
Thanks,
Harel