- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 12:21 AM
I often see both addEncodedQuery() and applyEncodedQuery() used in GlideRecord scripts — they seem similar, but are they really doing the same thing? When should I use one over the other, and are there cases where applyEncodedQuery() is actually better or more efficient?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 04:38 AM
addEncodedQuery() adds your condition before the query runs — it filters at the database level.
applyEncodedQuery() filters records after the query is already run — it works in-memory.
Use addEncodedQuery for performance. Use applyEncodedQuery when you already queried and want to re-filter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 01:44 AM
Hi @vikramkehar,
Consider this answer
https://www.servicenow.com/community/developer-forum/encoded-query/m-p/1825502
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 01:49 AM
Hi Vikram,
addEncodedQuery() - can be used just to query records
applyEncodedQuery() - Can be used to set field values on record insert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 04:38 AM
addEncodedQuery() adds your condition before the query runs — it filters at the database level.
applyEncodedQuery() filters records after the query is already run — it works in-memory.
Use addEncodedQuery for performance. Use applyEncodedQuery when you already queried and want to re-filter.