Set Email Subject from Email Script using Template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2017 02:43 AM
Hi All,
I'm stuck with some requirements that came our way. Basically we are trying to achieve two things -
1. We have wrote an Email Script to tag proper template to a notification(so the template is dynamic), to set the body we are simply using template.print and it is working fine. But we are not able to set the subject of the Email. It is not evaluating the variables present in the Email Template. So, if the subject is Incident Number: {number}. The same is printed as is. Need help here. The templates might be many and there might be many fields from Incident table in the template.
2. Based on certain conditions, we want to be able to either call another Email Script from one or a script include. I found on the community that we can simply call the script include like -
var sc = new ScriptIncludeName();
sc.functionName();
But again, this is not working. My script include atm only returns a static string.
Any help would be highly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2020 11:45 PM
Hi
I tried querying the sysevent_email_template table, and getting the subject from there for the current email template, and used that to setSubject() in the mail script, but it doesn't give me the evaluated field values, and the subject appears with the variable names as is.
I'd appreciate if you can throw some light on what exactly you did to get the evaluated subject line dynamically.
Thanks & Regards,
Rishabh Jha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2020 12:11 AM
Hi Rishabh,
Try this to set script in mail script to set dynamic subject in notification.
email.setSubject("Incident "+ current.number+" has been assigned to group"+ current.assignment_group);
Hope this will help you.
Regards,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2020 12:39 AM
Hi Sagar,
Thanks for the response. I have to use different email templates in a single email notification, based on the user selection, so the subject text and the variables would differ depending on the template selection, and I need to get the evaluated subject line for the selected email template, where the variables are replaced by the current object's values.
My requirement is similar to point # 1 mentioned by @bhawna in the thread above.
Thanks & Regards,
Rishabh Jha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2020 04:40 AM
Ok, so I got it working by parsing the subject through a custom evaluator and then setting the evaluated value to the email subject in the mail script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2021 08:57 AM
(function runMailScript(current, template, email, email_action, event) {
email.subject = 'My subject - ${category}';
})(current, template, email, email_action, event);
works for me.