ServiceNow outbound emails to populate recipient in BCC field and not the TO field for all notificat

Deepa Dhandapan
Tera Contributor

Reconfigure ServiceNow outbound emails to populate recipient in BCC field and not the TO field.
This way, when people receive a ServiceNow email and do a reply all... they will only be replying to the ServiceNow mailbox...
We need to create a script that will trigger BEFORE an email is sent,
and interrogate the TO field for any recipients starting with “SNOW-“ and move that recipient from the TO field to the BCC field.

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

HI @Deepa Dhandapan ,
I trust you are doing great.

Here's an outline of the solution:

  1. Log in to ServiceNow as an administrator.
  2. Navigate to "System Definition" -> "Business Rules" and click on "New".
  3. Provide a suitable name for the Business Rule, such as "Move SNOW Recipients to BCC".
  4. Set the "Table" field to "sys_email".
  5. In the "When to run" section, select the "Before" option and choose "Insert" and "Update" from the list.
  6. In the "Advanced" section, add the following script:

 

(function executeRule(current, previous /*, ...*/ ) {
  var recipients = current.recipients.split(',');
  var bccRecipients = [];
  var updatedRecipients = [];

  for (var i = 0; i < recipients.length; i++) {
    var recipient = recipients[i].trim();
    if (recipient.toLowerCase().startsWith('snow-')) {
      bccRecipients.push(recipient);
    } else {
      updatedRecipients.push(recipient);
    }
  }

  current.recipients = updatedRecipients.join(',');
  current.bcc = bccRecipients.join(',');

})(current, previous /*, ...*/ );

 

  1. Click on "Submit" to save the Business Rule.

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks for reply, i print the value To field and BCC value into system log and found that the to field value printing into both TO field and BCC field also. Pls find the attached screenshot.