Notification Email script with parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 07:49 AM
Hello ,
Can we use parameters when calling email script to do something like this : ${mail_script:show_informations("first info","second info")} ?
Thank you !
- 13,807 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 07:56 AM
Hi Abdel,
Unfortunately the mail script API does not allow parameters to be passed at this time. It does, however, have access to the event parameters and other objects.
Scripting for Email Notifications - ServiceNow Wiki
Email Notifications - ServiceNow Wiki
You could, potentially pass information via the event parameters if the message was generated from an event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2017 09:50 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here:
Scripting for Email Notifications
Create an Email Notification
Visit http://docs.servicenow.com for the latest product documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 07:57 AM
Hi Abdel,
Yes. Whatever your write inside mail script access the current record in notification and can access event parm1 and parm2.
Below should be format in the notification. The notification will automatically convert the mailx script part to a notification email script.
<mail_script>
show_informations("first info","second info");
function show_informations(p1,p2)
{
Your Script
}
</mail_script>
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 08:32 AM
thank you for the answers ,
Actually I have some email templates with a lot of links :
- <div>
- <h2> Links : </h2>
- <a href="link1">go</a>
- <a href="link2">go</a>
- <a href="link3">go</a>
- <a href="link4">go</a>
- <a href="link5">go</a>
- <a href="link6">go</a>
- </div>
And I need to add query string to each link using email script :
- <div>
- <h2> Links : </h2>
- <a href="link1?${mail_script:appendParamsLink1}">go</a>
- <a href="link2?${mail_script:appendParamsLink2}">go</a>
- <a href="link3?${mail_script:appendParamsLink3}">go</a>
- .
- .
- .
- </div>
- //appendParamsLink1 Email script for the first link
- printParams();
- function printParams(){
- template.print("param1=valueLink1¶m2=valueLink2..");
- }
The problem is I must have as much email script as links which is not easy to maintain.
That's why if we can call mail script with parameters it would be much easier :
- <div>
- <h2> Links : </h2>
- <a href="link1?${mail_script:printParams("value1","value2")}">go</a>
- <a href="link2?${mail_script:printParams("value1","value2")}">go</a>
- <a href="link3?${mail_script:printParams("value1","value2")}">go</a>
- .
- .
- .
- </div>
- //We can have a generic Email script for all the links
- function printParams(value1,value2){
- template.print("param1=value1 ¶m2=value2..");
- }
Maybe there an other way to do it ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 08:43 AM
Hi Abdel,
I would suggest building this whole thing using an email script. Dont call indivudual mail script. Starting from '<a href' , Everything should be in the mail script.
- <a href="link1?${mail_script:appendParamsLink1}">go</a>
- <a href="link2?${mail_script:appendParamsLink2}">go</a>
- <a href="link3?${mail_script:appendParamsLink3}">go</a>
- .
- .
- .
Please mark this response as correct or helpful if it assisted you with your question.