Need to send notification before 3 min of change start

Rushi2
Tera Expert

Hi All, 

 

I need to send a notification 3 min before the planned start date, I have written below the business rule it is triggering three notifications. Could anyone please help me figure out what the issue is here?

 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var gdt = new GlideDateTime(current.start_date);
    gs.log("planned start time 3 min before1: " +gdt);
    gdt.addSeconds(-180);
    current.start_date = gdt;
    gs.log("planned start time 3 min before2: " +gdt);
    gs.eventQueueScheduled('Unapproved.CHG.Before4Hrs.Nofication', current, '', '',gdt);

})(current, previous);
 
Thanks, 
Rushi
2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, I would not recommend a three minute window as a suitable production solution, as SNC email generation process includes a number of batch processes and these may consume a portion of this small time window, also depending on variables outside of SNC platform control email can often be delayed for periods exceeding 3 minutes.

 

Your post doesn't make it clear if this BR is triggered multiple times at one record update, or multiple times during the record lifecycle?
If all at one update you might need to check for recursive BR's triggering updates to current record, directly or via updates to other records and look at ways to resolve this.
If triggering multiple times individually, then either look at better trigger conditions for the BR, or you could include a scripted look up to see if the event was already created and only insert if it did not exist.

 

 

AshishKM
Kilo Patron
Kilo Patron

Hi @Rushi2 ,

I would suggest to handle this email triggering part at change's workflow level because it's already running on same change. Use the Timer/ Run Script and manage the notification, you can loop the same timer/runscript ( if required ) 

 

@Tony Chatfield1 has already shared the valuable details. Review it.

 

-Thanks

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution