addQuery LIKE returns 0 rows on RaptorDB – use CONTAINS or addEncodedQuer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Problem
A background script using addQuery('url', 'LIKE', 'assessment') returned 0 rows. The same filter in the list view returned many rows. Our daily counts showed 0, which looked like an outage. It was not.
Root cause
On our RaptorDB (Postgres-based) instance, addQuery with LIKE did not add the % wildcards. So it only matched values exactly equal to the text.
Fix
Use one of these instead:
- gr.addQuery('url', 'CONTAINS', 'assessment');
- gr.addEncodedQuery('urlLIKEassessment');
How to check on your instance
- Run the same filter both ways in a background script and compare the counts.
- Or build the filter in a list view, copy the query and use it with addEncodedQuery.
Tips
- After a database migration, re-check old diagnostic scripts. A result of 0 rows may be a query problem, not missing data.
- Text searches on URL fields can match encoded parameters in unrelated URLs. Keep the search text specific.
- The same applies to GlideAggregate. Compare with the list count before you trust the numbers.
Hope this helps someone. Happy to share more details if needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
A useful point to add here is that I would not assume this is a RaptorDB-specific behavior without verifying it on the instance.
A safer way to troubleshoot is to compare the same condition in the list filter and GlideRecord:
gr.addQuery('url', 'LIKE', 'assessment');
versus:
gr.addQuery('url', 'CONTAINS', 'assessment');
You can also build the filter in the list view, copy the encoded query, and test it with addEncodedQuery(). This helps confirm whether the issue is with the query/operator rather than the data itself.
Also, when a diagnostic script suddenly returns 0, always compare the script count with the corresponding list-view count before treating it as a data or platform issue.
If this helps, please mark it as Helpful and accept the solution.
Regards,
Tejas
