- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 03:14 PM
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?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 07:02 AM
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:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 08:04 AM
Awesome happy to help.