Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

 

 

 

1 REPLY 1

kaushal_snow
Giga 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/