How to change the header in notification

Asha Pathak
Tera Contributor

I have requirement where we need to change header in notification , How can I achieve it? Please help!

 

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Asha Pathak ,

If your instance is set up to use your organization's own mail server or a hosted service such as Office 365, it's recommended to set up a rule (using whatever mail server software/service you're using) to add the custom header. If that's not possible, or if you're using the ServiceNow mail infrastructure (the default option) you can use a Business Rule to insert the custom header (tested working on Madrid):

Create a Business Rule:

  • Name: "Add Custom Email Headers" (can be whatever you like)
  • When to run: before
    • Insert ticked
    • Update ticked
  • Order: 100
  • Advanced
    • Use the following script as an example (replace "X-MyCustomHeader" with the name of the header and current.instance with the variable or literal value that you want in the header:
      (function executeRule(current, previous /*null when async*/) {

         if(current.headers.indexOf("X-MyCustomHeader") < 0){
         current.headers = "X-MyCustomHeader:" + current.instance + "\n" + current.headers;
      }

      })(current, previous);

      Also, refer to this solution :https://www.servicenow.com/community/developer-forum/adding-extra-configuration-to-email-notificatio...

 

View solution in original post

5 REPLIES 5

Community Alums
Not applicable

Hi @Asha Pathak ,

If your instance is set up to use your organization's own mail server or a hosted service such as Office 365, it's recommended to set up a rule (using whatever mail server software/service you're using) to add the custom header. If that's not possible, or if you're using the ServiceNow mail infrastructure (the default option) you can use a Business Rule to insert the custom header (tested working on Madrid):

Create a Business Rule:

  • Name: "Add Custom Email Headers" (can be whatever you like)
  • When to run: before
    • Insert ticked
    • Update ticked
  • Order: 100
  • Advanced
    • Use the following script as an example (replace "X-MyCustomHeader" with the name of the header and current.instance with the variable or literal value that you want in the header:
      (function executeRule(current, previous /*null when async*/) {

         if(current.headers.indexOf("X-MyCustomHeader") < 0){
         current.headers = "X-MyCustomHeader:" + current.instance + "\n" + current.headers;
      }

      })(current, previous);

      Also, refer to this solution :https://www.servicenow.com/community/developer-forum/adding-extra-configuration-to-email-notificatio...

 

@Community Alums I have tried this , but on prod there was already set the header and no any business rule for it
How to set it by another way

Community Alums
Not applicable

Hi @Asha Pathak ,

How did you set it on Prod directly?

 

@Community Alums Yes we have to set it to directly prod, and the configuration is not on dev and test instance