Why event is triggering multiple time through workflow run script? Email logs received many time.

Anmol12
Tera Contributor

Hi,

I'm firing the event for a notification with below code but when I'm checking the email logs then I can seethe email logs generated many time for same notification. Is my code firing the event may time? 

 Can someone check please?

Workflow Run Script -

var approvers = [];

var getApprovers = new GlideRecord('sysapproval_approver');

getApprovers.addQuery('state', 'requested');

getApprovers.addQuery('group', current.task);

getApprovers.query();

while (getApprovers.next())

{

approvers.push(getApprovers.getValue('approver'));

}

gs.eventQueue('event,name', getApprovers, approvers, getApprovers.group.assignment_group_manager);

 

Notiication -

 

When to send - Event is fired

Who will receive - Send to Parm1

 

Please tell me why it's sending notification multiple time or event is firing multiple time?

7 REPLIES 7

Basheer
Mega Sage

Hi @Anmol12 

I think it is because there might be more than 1 approver to a record and the notification is being triggered to all the approvers and thats why you are seeing the log many a times.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Anmol12
Tera Contributor

Hi Basheer,

 

Yes there are more than one approver but what should I do to avoid this? I want to send only one notification to all recipients under Parm1.

@Anmol12,

How is the notification configured?  Does it have a link to the approval record? If it does you don't want to send the same email to every approver...the link will only work for one approver.   You'll be better off using User/Groups in fields on your notification and sending for each approval record.

Zaib Ali
Tera Contributor

Hi @Anmol12 

 

The reason it's showing multiple logs the one is you are sending notification to multiple recipients.

Navigate to

System Logs> Emails

check if the recipients are similar or unique.

 

Please mark the suggestion as helpful, if you find it useful to you or others who wants to refer similar content.
Please mark the solution as correct, if the answer provided has resolved your query.