Make CSM Email Notification Subject Line Dynamic

Mundo23
Giga Contributor

Does anyone know of a way to dynamically change the subject line of an auto email notification based on logic or conditions.  

 

Example:  Using the same email notification, with same sending trigger conditions or in the same flow/subflow, insert a subject line for one client, but a different subject line for a different client.  

 

 

1 REPLY 1

Tanushree Maiti
Giga Patron

Hi @Mundo23 

 

Use a Notification Email Script to evaluate conditions and override the subject line using email.setSubject().

Ref: Email Client Script Dynamically Changing Subject Line 

 

Step 1: Create the Notification Email Script

  • Navigate to System Policy > Email > Notification Email Scripts in your ServiceNow instance.
  • Click New.
  • Set the Name (like  set_dynamic_client_subject).
  • In the Script field, add your logic.

Sample code :

 

if (current.client == 'Client A') {

    email.setSubject("Important Update for Client A: " + current.number);

} else if (current.client == 'Client B') {

    email.setSubject("Important Update for Client B");

} else {

    email.setSubject("General Notification: " + current.short_description);

}

 

Step 2: Add the Script to your Notification

  • Open the Email Notification you want to send.
  • Call email script from within the body : ${mail_script:set_dynamic_client_subject}

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: