Email Notification scripts work fine. Email Template scripts not being detected.

awright
Kilo Expert

Hi all,

Email template scripting is not working even though our instance has many examples of email notifications that contain scripting using mail_script tags that we have used reliably for a long time.

Recently I attempted to use mail scripting in an email template as part of a calendar request because the wiki says that scripting in email templates should behave exactly the same as scripting in email notifications. The problem is that the mail_script tags and everything inside them appear to be printed verbatim on to the template. This is the first time we have encountered this problem as we have not used the email scripting functionality on email templates before, only on notifications.

The only thing that we can think of that is changing the behaviour is that the email notification is of the type Meeting Invitation, though there is nothing on the wiki saying that a calendar type message does not allow scripting.

Any hints as to what may be causing the mail_script XML tags and everything between them to be printed as-is to the template would be appreciated, though the reason I put this in the something amiss section is because we cannot find anything in the documentation telling us that what we are doing should not be possible, and I have seen no complaints about this on a search of the community.

4 REPLIES 4

Ian Kirby1
Giga Expert

I suspect that you are correct in your thinking:
"The only thing that we can think of that is changing the behaviour is that the email notification is of the type Meeting Invitation, though there is nothing on the wiki saying that a calendar type message does not allow scripting."

We use templates with mail scripts in for Incident, Problem and Task notifications. The notifications using the templates are using the EMAIL type. These work fine, so I can confirm that mail scripting is processed for a template. I've not used the Meeting Invitation type, so I can't confirm there I'm afraid.

Regards,
Ian


CapaJC
ServiceNow Employee
ServiceNow Employee

It would not surprise me if, when email notifications were enhanced to provide support for mail scripts, the code that builds Meeting Invitations was not similarly enhanced. My impression is that meeting invitations are used far, far less than email notifications, and trying to use a mail script in one is rarer still. You might be the first one!

If you put your mail script into the Email Notification vs. the template, does it work then? I think that would surprise me a little.

Either way, you should probably just open an Incident with Customer Support, since this sounds like something that should be made to work as you expect.


Even though it is a bit surprising, I've actually found mail scripts can be included in a notification that applies an invite template.

For example, I'm using the 'Notify Change Calendar' notification, which applies the 'change.calendar.integration' template. If I add mail scripts in the 'change.calendar.integration' template, they are not processed. If I add mail scripts to the "Message" section of the 'Notify Change Calendar' notification, they are processed. Unfortunately, this may only allow you to apply scripts to the invite body--email.setBody()/template.print()--and subject--email.setSubject()--but those were the two areas I was looking to change, so it's been a good workaround for me.


Mike McCall
Giga Guru

I had actually been encountering the exact situation that you describe, and since I had the same problem of finding no answers, I was lucky enough to get that particular request downgraded in priority. Unfortunately, it's finally time to give that user an answer!

Have you had any luck with Support on determining whether or not mail scripts can be used in calendar templates?