Quantcast
Channel: Cloud Sherpas » Valor Poland
Viewing all articles
Browse latest Browse all 11

ServiceNow Tech Tuesdays: Using Static and Dynamic Queries to Filter Lists in ServiceNow

$
0
0

As a part of this mini-series on underutilized features of ServiceNow, we’ll now cover the Fixed Query. This is documented on the wiki, but I’d like to add some more context here.

The base configuration of ServiceNow does not allow ESS users (“Joe Employee”) to filter incidents in their list by using the the breadcrumb query builder. They can, however, right-click in a list cell and “Show matching” or “Filter out”, effectively building their query that way. This is a bit problematic, as they actually can filter, but they cannot remove or see the filters applied.

This is where the Fixed Query comes in. Why don’t we show them the base (default) filter that is applied, but disallow its removal?

As an Administrator, when I click the Self-Service > Incidents module, I see this filter (Caller is me, Active is true):

In my last post, we were introduced to the the “copy query” functionality that allows us to get the Encoded Query string. For the uninitiated, an encoded query is roughly a URL-friendly (URL encoded) way to designate a SQL “WHERE” clause.

Let’s do that here:

Query: caller_id=javascript:gs.getUserID()^active=true

 

Next, we must convert that query from a dynamic to a static one–a query that we can add to, but not eliminate. To do this, we need to edit the module to remove the dynamic filter, then set the “Arguments” field to &sysparm_fixed_query=encoded_query (you may have to change the “Link type” to List of Records):

One final thing we have to do (and this only because we’re trying to grant non-roled users filter permissions), is to add a simple script include named “incidentDisplayFilter.”

Script:

function incidentDisplayFilter () {

  return true;

}

 Finally, let’s test it!

 

We now see that instead of “All” being the first linked breadcrumb, “Active is true” is the first clickable crumb.

One security note on this feature: just because you can’t click off of the filter, does not mean that the filter will be applied everywhere. This is not a substitute for proper ACL rules.

In closing, we want this blog to be helpful to you, the reader. Please comment with feedback and additional questions or suggestions for future Tech Tuesday blog posts!

The post ServiceNow Tech Tuesdays: Using Static and Dynamic Queries to Filter Lists in ServiceNow appeared first on Cloud Sherpas.


Viewing all articles
Browse latest Browse all 11

Trending Articles