Auto forward of email to particular email address.

Ravi Kiran
Kilo Guru

Hello,

 

I have written below BR to auto forward the email with condition state is ignored and body contains bds then it should forward to mail address . BR is working and sending email to provided mail address but same email sent 23 times . Not sure what could be the issue to receive 23 times every time when ever the BR conditions matches and run.

 

Table - sys_email

when - after update 

filter condition  - State is ignored and Body contains bds


(function executeRule(current, previous /*null when async*/) {
 
    gs.log("Business Rule 'Forward Ignored BDS Emails' started for email record: " + current.sys_id);
       
         var email = new GlideRecord('sys_email');
        email.initialize();
        email.type = 'send-ready';
        email.subject = current.subject;
        email.body = current.body;
        email.recipients = 'r.ravikiran@xxx.com'; //email marked xxx.com here but actual email address is added in code
        email.insert();
       
        // Log email forwarding success
        gs.log("Email forwarded successfully to r.ravikiran@eviden.com for email record: " + current.sys_id);
  
})(current, previous);
 
Thanks in advance.
 
Regards
Ravi Kiran
1 ACCEPTED SOLUTION

HIROSHI SATOH
Mega Sage

Your issue of the email being sent 23 times may be caused by how the Business Rule (BR) is triggering. Since the BR runs "after update", every time the sys_email record gets updated, the BR will execute again, possibly in a loop. This can happen because the BR itself is creating a new email record, and if the update condition is met multiple times, the BR keeps firing.

Try adjusting the trigger conditions.

View solution in original post

2 REPLIES 2

HIROSHI SATOH
Mega Sage

Your issue of the email being sent 23 times may be caused by how the Business Rule (BR) is triggering. Since the BR runs "after update", every time the sys_email record gets updated, the BR will execute again, possibly in a loop. This can happen because the BR itself is creating a new email record, and if the update condition is met multiple times, the BR keeps firing.

Try adjusting the trigger conditions.

Thanks @HIROSHI SATOH , i changed filter condition  - State changes to ignored and Body contains bds. it worked