Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Advanced condition in business rule is not working( two not equal to condition)

Anitha33
Kilo Explorer

Requirement :  to run BR when current logged in user is not the problem manager or not belongs to the role "thd pm admin".

 

Advanced condition:

gs.getUserID() !=  current.u_problem.u_problem_manager || !gs.hasRole('thd pm admin')

 

 

If I give one condition (gs.getUserID() !=  current.u_problem.u_problem_manager)  alone its working 

If I give one condition (!gs.hasRole('thd pm admin'))  alone its working.

If I give both the condition in advanced condition its not working(OR operators is not working for two condition).

 

 

Please suggest immediately.

 

 

 

 

find_real_file.png

1 ACCEPTED SOLUTION

Brent Sutton
Mega Sage

Hi Anitha,

I think you should be using AND instead of OR. Should look like the following: -

(gs.getUserID() !=  current.u_problem.u_problem_manager) && (!gs.hasRole('thd pm admin'))  

Let me know if this worked for you,

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

View solution in original post

9 REPLIES 9

SaiRaviKiran Ak
Tera Guru

Try

(gs.getUserID() !=  current.u_problem.u_problem_manager) || (!gs.hasRole('thd pm admin'))

Did you try the above condition ?

Tried && operator, its working fine. Thanks for the suggestion.

Can't understand the logic, if we are using && operators both condition should satisfy then only BR will run but here if im using && operator BR is running if one condition satisfies also.

 

Why || operator is not working here.

Brent Sutton
Mega Sage

Hi Anitha,

I think you should be using AND instead of OR. Should look like the following: -

(gs.getUserID() !=  current.u_problem.u_problem_manager) && (!gs.hasRole('thd pm admin'))  

Let me know if this worked for you,

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.