Encoded Query & Add Or Condition query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 01:54 PM
Hi All,
I am stuck on a scenario where I need to query records from a table with the combination of one encoded query saved in a field or on the basis my static query.
For ex: I need to fetch incident tickets where active is true or my encoded query matches.
I tried following query but it seems addEncodedQuery method doesn't work with addOrCondition method.
current.addEncodedQuery("short_description=Test").addOrCondition("active","true");
Does anyone know how to make both Encoded query & addOrCondition working together? Please HELP!!
Thanks in advance,
Inderpal Singh
ipsindhuria1992@live.com
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 02:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 06:18 PM
Hi Mike,
Thanks for replying.
The problem is not this much simple. Sorry I didn't explain the scenario in detail.
I want to use these queries in Before Query Business rule on Incident table. Problem in using "^NQ" in encoded query of before query business rule is that when system queries record from table, it always forces the records matching the query coming after ^NQ irrespective of the filter I have applied on the List filter.
See below screenshot for the reference.
Issue here is if I am applying any filter on the list, my before query business rule always pushing the data matches query after ^NQ on the list.
Below is my encoded query which I have used in before query business rule.
current.addEncodedQuery('active=true^NQcaller_idSTARTSWITHLHR User')
Because of this below filter is not working properly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 07:21 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 06:34 PM
Perhaps this post will be helpful
How To Write GlideRecord Queries Like A Pro - Encoded Queries
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022