Adding a condition to BR user query

oharel
Kilo Sage

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

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee
7 REPLIES 7

Abhinay Erra
Giga Sage

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


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Harel,



You may also find below link helpful for reference.


Controlling record access using 'Before Query' business rules - ServiceNow Guru


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