Make encoded query readable via script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 08:18 AM
Hi there,
We want to make an encoded query readable (= eye friendly for end users) via script, after retrieving it from a table. So once we have the condition string (can contain anything like =, IN, BETWEEN...), we would like to deconstruct and "translate" it for human eyes, and return it as a string.
Before we start splitting it into arrays, or playing with RegEx - did anyone already take the time to do the same? Is there maybe a script snippet which we could use?
Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 09:17 PM
Create a script to decode the encoded query
- Use a decoding algorithm to interpret the encoded query
- Use a library of functions to decode the query
- Use a text editor to view the decoded query
- Use a debugging tool to check for errors in the decoded query
- Test the decoded query to ensure it is readable
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 12:14 PM - edited 06-10-2025 12:16 PM
@Stefan Reichelt there is a undocumented API called GlideQueryBreadcrumbs.
This API has a method getReadableQuery(<table_name>, <encoded_query>).
var encoded_query = "active=true^category=hardware^ORpriority=1";
var table_name = "incident";
var readableQuery = new GlideQueryBreadcrumbs().getReadableQuery(table_name, encoded_query );
gs.print("Readable Query: "+readableQuery);
//output - Readable Query: Active = true .and. Category = Hardware .or. Priority = 1 - Critical
Please test using the above code in background script.
I got the above API from an OOTB script include SLATimeLineV2SNC.
If my response helped you then please mark the response helpful and accept the solution.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 04:17 AM
@Stefan Reichelt, did the GlideQueryBreadcrumbs worked?