- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:10 PM - edited 12-05-2023 11:11 PM
Hi,
I have a situation here where I would like to add multiple ADD condition to addEncodedQuery.
Currently I have:
gr.addEncodedQuery("u_audit_planned_nextISNOTEMPTY^parent=b3f0fa471bxxxxx^u_type=Subsidiary");
But for variable 'u_type', I also need to add Production along with Subsidiary
I have tried
gr.addEncodedQuery("u_audit_planned_nextISNOTEMPTY^parent=b3f0fa471bxxxxx^u_type=Subsidiary^Production");
but didnt work out.
Any leads on this problem?
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:37 PM - edited 12-05-2023 11:52 PM
Hi,
To add multiple conditions with OR logic in ServiceNow using `addEncodedQuery`, you need to enclose the conditions in parentheses and use the OR operator (`^OR`). Here's how you can modify your query:
gr.addEncodedQuery("u_audit_planned_nextISNOTEMPTY^parent=b3f0fa471bxxxxx^u_type=Subsidiary^ORu_type=Production");
This query will retrieve records where `u_audit_planned_next` is not empty, `parent` is equal to "b3f0fa471bxxxxx," and `u_type` is either "Subsidiary" or "Production."
Remember to replace the field names and values with your actual field names and desired values. The key here is to group the conditions for `u_type` within parentheses and use the `^OR` operator between them.
Please mark it helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:37 PM - edited 12-05-2023 11:52 PM
Hi,
To add multiple conditions with OR logic in ServiceNow using `addEncodedQuery`, you need to enclose the conditions in parentheses and use the OR operator (`^OR`). Here's how you can modify your query:
gr.addEncodedQuery("u_audit_planned_nextISNOTEMPTY^parent=b3f0fa471bxxxxx^u_type=Subsidiary^ORu_type=Production");
This query will retrieve records where `u_audit_planned_next` is not empty, `parent` is equal to "b3f0fa471bxxxxx," and `u_type` is either "Subsidiary" or "Production."
Remember to replace the field names and values with your actual field names and desired values. The key here is to group the conditions for `u_type` within parentheses and use the `^OR` operator between them.
Please mark it helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:56 PM
Thanks @Iraj Shaikh.
This fixed my problem!