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

How to get the display value of an encoded query?

MG Casey
Mega Sage

Is there an easy way to convert an encoded query such as:

active=true^caller_id!=3643044b6ff851406b7283bc5d3ee42b^ORcaller_id=NULL

to make it look how it looks at the top of a ServiceNow list?

find_real_file.png

All > Active = true > Caller != Data Center Operations

For custom applications, allowing users to see a more readable version of their current filters would help tremendously. I'm just curious how ServiceNow does it for their own lists.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

When using a condition field, you can use the dictionary attribute readable=true, that way if someone has it displayed on a list or in a read-only field, it will still be readable.



For example: Active = true .and. Caller = Fred Luddy .or. Caller is empty



http://wiki.servicenow.com/index.php?title=Dictionary_Attributes#gsc.tab=0


View solution in original post

9 REPLIES 9

Chuck,

 

Are there any exposed functions that can return the readable format on the server side?  Use case is, if I'm using GlideFilter to check a record against a series of conditions, and I want to log/note the reason why it was excluded from the rest of the function, I'd like that to be in a readable format.

I've done some looking and experimenting, but I don't see anything. There must be a way because it's how the breadcrumbs are displayed, but I don't see any API that makes it available to the rest of the world. If I hear of anything, I'll be sure to post.

I did some checking with our API team and came up with this. It only works in global. No word on a scoped version yet. I haven't tried the script include workaround yet.

I believe the two arguments are tablename and encoded query string (substitute with field values in this example.)

gs.info(new GlideQueryBreadcrumbs().getReadableQuery('incident','active=true^caller_id=46c9e158a9fe198101d44d0d22cb640d'));
 
*** Script: Active = true .and. Caller = Chuck Farley

 

 

Thank you, this is definitely something to go on.  I appreciate the help.

Thanks man, I'm gonna need to check these things out