- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 08:42 AM
Below is the code which triggers event but event's state turns to ERROR, please find screenshot also
var gr = new GlideAggregate("sysapproval_approver");
gr.addQuery("state", "requested");
gr.addAggregate("COUNT", "approver");
gr.query();
while(gr.next()){
gs.eventQueue("send_approval_reminder",gr, gr.approver, gr.approver.getDisplayValue());
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 10:08 AM
Hey guys, thanks all for your help and putting time into it, I was able to figure out this
I stored approver sys ids into an array and then looped it for triggering email.
That Worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 09:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 09:57 AM
Could you provide one more information?
Does column Instance of those event records contain anything - I expect it is empty (because GlideAggregate).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 10:00 AM
yes , thats empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 10:06 AM - edited ‎03-09-2023 10:07 AM
That is most likely the problem here: something reacting to the event is trying to reconstitute the record, but it will fail as it has no sys_id to go with.
Try modifying the event definition to point to the User table instead.
At the same time fetch the user record in the script and use that as 2nd parameter to gs.eventQueue().
Something like:
var gr = new GlideAggregate("sysapproval_approver");
gr.addQuery("state", "requested");
gr.addAggregate("COUNT", "approver");
gr.query();
while (gr.next())
notifyUser('' + gr.approver);
function notifyUser (uniqueValue) {
var sys_user = new GlideRecord('sys_user');
if (sys_user.get(uniqueValue))
gs.eventQueue("send_approval_reminder", sys_user, sys_user, sys_user.getDisplayValue());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 10:08 AM
Hey guys, thanks all for your help and putting time into it, I was able to figure out this
I stored approver sys ids into an array and then looped it for triggering email.
That Worked