- 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-23-2016 08:53 AM
Hi Josh
On which version of Snow are you working at the moment ?
I've noticed that in some cases using the RichText Editor on email if you cut and paste something like your code
e.g. ${email_script:yourScriptName}
the system copy something like
${email_script:<tag>yourScript}
This means that in the editor seems clean but behind the scenes will not work.
Try to check HTML Source code.
Cheers
Ivano
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2016 09:30 AM
Hello Ivano--
Thanks for the reply. We're using Geneva.
I checked the source code in my footer template and it looks correct:
<p></p>
<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 ${mail_script:GetYear} 2016 • 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>
<p> </p>
<p><!-- end content block --></p>
<p> </p>
<p> </p>
<p>template.print(gdt.getYear()); ;</p>
What do you recommend?
josh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2016 11:37 PM
Hi Josh,
For footer you can write below given mail script and add this at the end of either notification or your footer template.
Mail Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var time=gs.now();
var SplitTime=time.split('-');
var Year=SplitTime[0];
template.print(Year);
})(current, template, email, email_action, event);
I am not sure it is your requirement or not ,if not please clarify your issue again.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2016 03:37 AM
Thank you for the reply, Farukh. It looks like you've provided a mail script for getting the current year, but I already have this. Here's what I'm trying to do: I've making an email notification and in the message box it looks like this:
${mail_script:Header}
[Body of the email]
${mail_script:Footer}
See below...
All this is fine and good. But see the {mail_script:footer} in the screen shot above? That footer mail script points to a template (the code for which is provided in my 9/23 9:30am reply) that contains another mail script. This mail script (${mail_script:GetYear}) works fine if I put it directly into the notification, as I've already done with the footer and header. But it doesn't work when placed in the footer template. This is what the notification now looks like...
Thanks again for any help you can provide.
josh