- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 08:34 AM
In a script include, is there a way to run an encoded query against the current record and return if it has a match ?
Intend to make Assignment Rules a lot easier for the end users and a lot more flexible. It works fine on a record that has been saved and then edited, but if course a new record does not work.
The code will get all of the lookup records that match the target table and quickly determines which rule will match the target record in its' table. If there is a match it will set the assignment group based on the next steps.(It knows the sys_id of the current record so is looking for that with the matching condition sys_id=123123^category=software.....)
Of course, as that is querying the target table (incident, change_request etc) it needs the record to exist to work
When creating a new record, when the assignment code runs I can see that current exists, but until the record is saved the query will fail as it is not in the table. I want to avoid an insert with an immediate update (which does work)
I was hoping that by doing a current.addEncodedQuery('bla bla') that may work, but it does not.
Anyone have any other ideas - I don't really fancy trying to break down a query string and going down that route
TIA
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 07:41 AM
Hi poyntzj,
I would suggest you try using GlideFilter. Here's a reference, take a look.
It does essentially what you ask, comparing a GlideRecord to a string filter (encoded query). Give that a try and see if it works for your scenario.
Thanks,
-Brian
Edit:
Here's an example used in an on Before business rule for Incident:
(function executeRule(current, previous /*null when async*/) {
// If the Impact is HIGH, set the Urgency to HIGH as well.
var bool = GlideFilter.checkRecord(current, "impact=1");
if(bool){
current.setValue('urgency', 1);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 07:41 AM
Hi poyntzj,
I would suggest you try using GlideFilter. Here's a reference, take a look.
It does essentially what you ask, comparing a GlideRecord to a string filter (encoded query). Give that a try and see if it works for your scenario.
Thanks,
-Brian
Edit:
Here's an example used in an on Before business rule for Incident:
(function executeRule(current, previous /*null when async*/) {
// If the Impact is HIGH, set the Urgency to HIGH as well.
var bool = GlideFilter.checkRecord(current, "impact=1");
if(bool){
current.setValue('urgency', 1);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 01:43 AM
Works a treat. Never knew about this little nugget before

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 07:23 AM