The CreatorCon Call for Content is officially open! Get started here.

Multiple Notifications Triggered When Using gs.eventQueueScheduled() in Business Rule

SREEKANTH_P
Tera Contributor

Hi all,

I have a requirement to send two email notifications for Change Requests of type Normal:

When the Implementation Start Date is reached

When the Implementation End Date is reached

I'm using a Business Rule that triggers an event using gs.eventQueueScheduled() at the scheduled time. The logic works as expected, and the notifications are sent at the correct time.

However, the issue is that the notification is being triggered more than once, causing duplicate emails.

 

Can anyone please suggest why this may be happening and how to ensure the event/notification is triggered only once?

Thanks in advance for your inputs!

 

SREEKANTH_P_0-1760270189832.png

 

 

SREEKANTH_P_1-1760270256988.png

 

 

SREEKANTH_P_2-1760270448146.png

 

 

 

3 REPLIES 3

Bshirisha
Tera Contributor

Hello @SREEKANTH_P 

Since you're using an 'After Update' Business Rule, is there anything in the system (like a script, Flow, or another Business Rule) that might be updating the record again after it's saved? That could be triggering the rule multiple times and causing duplicate notifications.

 

kaushal_snow
Mega Sage

@SREEKANTH_P ,

 

 

The duplicates are happening because every time your Business Rule fires you call gs.eventQueueScheduled() without first checking whether there’s already an unsent (sysevent.state = ready) event for that same event name, table and record, so as a best practice before scheduling a new one run a GlideRecord query on the sysevent table filtering by state = ready, your event name, table = current.getTableName(), instance = current.sys_id, delete all matching ready events, and then call gs.eventQueueScheduled so you guarantee only one pending event exists at a time, effectively preventing duplicate emails.......

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Ankur Bawiskar
Tera Patron
Tera Patron

@SREEKANTH_P 

Try updating the condition as 

State [Changes to] Scheduled

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader