Dynamic Email Subject

shaik_irfan
Tera Guru

Hi,

 

On the incident notiication we wan to set the dynamic subject like 

if Priority 1 incident then the subject should be: Action required on incidnet #

if Priority other than 1 then subject should be incident # updated 

 

Can anyone please help me how to do this

1 ACCEPTED SOLUTION

Hi Irfan,

 

You need to create mail script named setSubjectDynamically as below

(function runMailScript(current, template, email, email_action, event) {

          // Add your code here
	if(current.priority==1) //try passing '1' in quotes if this does not work
		{
			email.setSubject('Action required on incident '+current.number);
		}
	else
		{
			email.setSubject('Incident '+current.number+' updated.');
		}
		

})(current, template, email, email_action, event);

 

Call the mail script in the notification body in format

${mail_script:setSubjectDynamically}

View solution in original post

3 REPLIES 3

Matthew Glenn
Kilo Sage

Look into Notification Email Scripts. Will allow you to dynamically insert/change subject, body, recipient, etc based on attributes from the current record, all while using a single notification record.

Hi Irfan,

 

You need to create mail script named setSubjectDynamically as below

(function runMailScript(current, template, email, email_action, event) {

          // Add your code here
	if(current.priority==1) //try passing '1' in quotes if this does not work
		{
			email.setSubject('Action required on incident '+current.number);
		}
	else
		{
			email.setSubject('Incident '+current.number+' updated.');
		}
		

})(current, template, email, email_action, event);

 

Call the mail script in the notification body in format

${mail_script:setSubjectDynamically}

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to write email script for achieving this functionality and use this email script in email notification.

Use below email script

 

 

if(current.priority == 1)

email.setSubject("Action required on incidnet " + current.number);



else



email.setSubject(" incidnet " + current.number + " is updated");

 

 

Regards,

Sachin