How to set OR condition in Business rules?

Summer
Kilo Contributor

Hi guys.

Do you know how to set OR condition aside from using " || " in code?

I tried to use " || " but it seems like the "||" is not working at all

Condition : if location is "us" and service is "Functions" OR if location is "us" and service is "Technology" and startdate is starting from February 1, 2022 onwards.

 

Code:

else if (((gr_location == 'us') && (current.u_service != 'Functions')) || ((gr_location == 'us') && (current.u_service != 'Technology') && (current.Startdate >='2022-02-01'))) {

 

TIA!

3 REPLIES 3

Saurav11
Kilo Patron
Kilo Patron

Hello,

if you are gliding table and using gr it will be gr.location instead of gr_location

else if (((gr.location == 'us') && (current.u_service != 'Functions')) || ((gr.location == 'us') && (current.u_service != 'Technology') && (current.Startdate >='2022-02-01')))

Please mark answer correct/helpful based on Impact.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

it should work fine using ||

Are you using correct pair of round braces in condition

Can you share complete condition/script?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Abhijit4
Mega Sage

Hi,

OR works fine in scripting, you might be making some mistake. Could you please share record values for which you are testing, What are you expecting and what system is performing so that we could help you with problem details.

And I think there is problem with your code, normally field backend names are all small letters so "current.Startdate" should be "current.startdate".

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP