How to set OR condition in Business rules?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 12:15 AM
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!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 12:49 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 12:55 AM
Hi,
it should work fine using ||
Are you using correct pair of round braces in condition
Can you share complete condition/script?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 12:58 AM
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
Regards,
Abhijit
ServiceNow MVP