- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2016 08:36 AM
Hello. Thanks in advance for your help. I've seen a number of discussions on how to do add an email script to an email template, but it isn't working for me.
Scenario: I have a notification where I add header and footer templates by using a ${mail_script:header} and a ${mail_script:footer} email script.
In the footer template, I would like to include an email script that updates the year automatically. However, when the footer template is added into the notification, the email script (mail_script:GetYear) doesn't convert to the year. However, it works fine if I keep it in the notification, which is not what I want...
Any advice?
Thanks again,
josh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2016 09:50 AM
Hi Josh,
Sorry!!! I don't know why this is not working .May be what Berny mentioned above that can be the reason . If not then you can achieve this by writing a script include and calling it from mail script.
Script Include:
Name: EmailUtils
Client Callable:Unmarked
Active:Marked
Script:
var EmailUtils = Class.create();
EmailUtils.prototype = {
initialize: function() {
},
emailFooter: function(){
var time=gs.now();
var SplitTime=time.split('-');
var Year=SplitTime[0];
var Emailfooter='<table id="body" style="width: 100%; height: 100%; border-collapse: collapse; background-color: #f5f5f5;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f5f5f5"><tbody><tr><td align="center" valign="top" bgcolor="#f5f5f5" width="100%" height="100%"> </td></tr><tr><td style="width: 550px; height: 20px;" width="550" height="20"> </td></tr><tr><td style="width: 550px; font-size: 11px; font-family: Arial, Helvetica, sans-serif; color: #333; text-align: center; line-height: 19px;" align="center" width="550">Liberty University Information Technology<br /> 1971 University Boulevard • Lynchburg, VA 24515 • (866) 447-2869<br /> © Copyright '+Year+' • Liberty University is a Registered Trademark • <a href="http://www.liberty.edu/index.cfm?PID=6901">Privacy Policy</a></td></tr><tr><td style="width: 550px; height: 30px;" width="550" height="30"> </td></tr></tbody></table>';
return Emailfooter;
},
type: 'EmailUtils'
};
Email Notification Script:
Name:email_footer
Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var emailUtils = new EmailUtils();
template.print("<tr><td>"+ emailUtils.emailFooter() +"</td></tr>");
})(current, template, email, email_action, event);
Notification:
Message HTML:${mail_script:email_footer}
Notification Preview:
Let me know for further queries ............
Thanks,
Farukh
Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2016 06:29 AM
Hi Josh,
Could you please confirm me that is 'footer' template or mail script ? ,as you are calling it by using ${mail_script:footer} so it looks like a another one mail script which containing 'GetYear' mail script.
Thanks,
Farukh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2016 04:18 AM
Faruk,
The ${mail_script:footer} grabs the html from the footer template (a trick I learned from this discussion:Re: Apply Email Template in Notification😞
In this case, the template is one whose html is provided in my 9/23 9:30am reply.
Thanks,
josh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2016 06:44 AM
Hi Josh, try Footer with the F in upper case since that's how your mail script is named.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2016 06:45 AM
In other words, use the following:
${mail_script:Footer}
instead of...
${mail_script:footer}
I hope this helps!
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2016 09:50 AM
Hi Josh,
Sorry!!! I don't know why this is not working .May be what Berny mentioned above that can be the reason . If not then you can achieve this by writing a script include and calling it from mail script.
Script Include:
Name: EmailUtils
Client Callable:Unmarked
Active:Marked
Script:
var EmailUtils = Class.create();
EmailUtils.prototype = {
initialize: function() {
},
emailFooter: function(){
var time=gs.now();
var SplitTime=time.split('-');
var Year=SplitTime[0];
var Emailfooter='<table id="body" style="width: 100%; height: 100%; border-collapse: collapse; background-color: #f5f5f5;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f5f5f5"><tbody><tr><td align="center" valign="top" bgcolor="#f5f5f5" width="100%" height="100%"> </td></tr><tr><td style="width: 550px; height: 20px;" width="550" height="20"> </td></tr><tr><td style="width: 550px; font-size: 11px; font-family: Arial, Helvetica, sans-serif; color: #333; text-align: center; line-height: 19px;" align="center" width="550">Liberty University Information Technology<br /> 1971 University Boulevard • Lynchburg, VA 24515 • (866) 447-2869<br /> © Copyright '+Year+' • Liberty University is a Registered Trademark • <a href="http://www.liberty.edu/index.cfm?PID=6901">Privacy Policy</a></td></tr><tr><td style="width: 550px; height: 30px;" width="550" height="30"> </td></tr></tbody></table>';
return Emailfooter;
},
type: 'EmailUtils'
};
Email Notification Script:
Name:email_footer
Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var emailUtils = new EmailUtils();
template.print("<tr><td>"+ emailUtils.emailFooter() +"</td></tr>");
})(current, template, email, email_action, event);
Notification:
Message HTML:${mail_script:email_footer}
Notification Preview:
Let me know for further queries ............
Thanks,
Farukh
Hit like, Helpful or Correct depending on the impact of the response