The CreatorCon Call for Content is officially open! Get started here.

Make encoded query readable via script

Stefan Reichelt
Tera Guru

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!

3 REPLIES 3

sourav1999
Mega Guru

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

ahan
Tera Guru

@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!!

@Stefan Reichelt, did the GlideQueryBreadcrumbs worked?