Notification Email Scripting - Passing a Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2014 05:35 PM
Is it possible to pass a variable to a Notification Email Script from the Notification that calls it?
I have the following Notification Email Script:
var gr = new GlideRecord('u_common_email_text');
gr.addQuery('u_active', true);
gr.addQuery('u_name', 'cmn_footer_en');
gr.query();
if (gr.next()) {
template.print(gr.getValue('u_html'));
}
It is called from a Notification using the following statement: ${mail_script:ACME_cmn_footer}
The script looks up a common footer in English ("cmn_footer_en") to display on our English notifications. I would like to have it be more dynamic so that I can pass it the footer text I want it to look up, so that I do not need to create a script in each of the 10 languages we support in our instance.
I was looking to change the call in the calling Notification to something like: ${mail_script:ACME_cmn_footer("cmn_footer_en")}. However, I do not know how to read the value in the script. Is this even possible to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2016 05:58 AM
In the mail script you could look up the Users Language pref (the User who is receiving the notification)
var theUser = gs.getUser()
theUser = theUser.getUserByID(emailrecipient);
var lang = theUser.getLanguage();
'cmn_footer_en' can then be swapped for a variable and calculated dynamically using a switch statement if you know how?
so whatever the users language preferences it will match the correct footer.
If you need the code msg me back and I will see if I can help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:02 AM
Hi James,
This might be helpful: The event.parm1 and event.parm2 parameters that come from the originating event can also be used within the <mail_script>. To use these, enter event.parm1 or event.parm2 in the mail script.
Regards,
Hardik Vora