- 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 08:54 AM
Hi,
Is there a reason you're using GlideAggregate for this?
I'd recommend switching to GlideRecord API instead and removing the count addAggregate because you're not using it anyway?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 08:56 AM
The scenarios is- I have to get unique entries of approvers who have approvals pending

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 09:08 AM - edited ‎03-09-2023 09:11 AM
Well, you are, by looking at the state and seeing that it's requested.
So it will only return records in that state and you're while looping through them and firing an event for each one.
And as you see below, they're mentioning the same thing I did above, you'd need to use GlideRecord for this.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2023 09:23 AM
I may be not understanding your solution but let say there are 10 approvals pending for user1 and 100 for user2
if I use GlideRecord it will trigger total 110 event and they will generate separate notification which will spam user
if I get unique value somehow(for same I am using glideaggregate) which will return only 2 events