Determine if current object would be captured in a query

steph3
Tera Contributor

Is there a way to determine if a current object would be captured in a query that has not been inserted? So for example, if a record is not yet inserted and you only have the current object but wanted to determine if it matched up to be captured in a query. Obviously you wouldn't be able to use a gliderecord because it hasn't been inserted. Is there another way?

1 ACCEPTED SOLUTION

If you already have an encoded query and you want to compare it to an object you can use GlideFilter.checkRecord(GlideRecord, EncodedQuery).

So for example:

find_real_file.png

 

If I want to validate whether the incident's caller is Joe Employee and priority is one and incident is active, the encoded query is:

var query = "active=true^priority=1^caller_id=681ccaf9c0a8016400b98a06818d57c7";

Here is a background script I use to test the encoded query against the incident:

var incident = new GlideRecord("incident");
incident.get("695505ca4f629b00d1676bd18110c7b3");
var query = "active=true^priority=1^caller_id=681ccaf9c0a8016400b98a06818d57c7";

var queryMatch = GlideFilter.checkRecord(incident, query);
gs.print("queryMatch: " + queryMatch);

The queryMatch variable will be true if it matches and false if not.  Here is the result:

*** Script: queryMatch: true

Please mark any post as helpful or the correct answer to your question so others viewing can benefit.

 

View solution in original post

5 REPLIES 5

Awesome happy to help.