- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:31 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:01 PM
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:39 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:01 PM
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}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:43 AM
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