The CreatorCon Call for Content is officially open! Get started here.

Define an email script to work like a function? E.G. ${mailscript:myscript('sys_id')}

joshuamayes
Giga Expert

I want to define a mail script that will insert the content of a knowledge article.  I also don't want to have to use a separate mail script for each KB we want to use in our notifications.  

I'm wondering if there is a way to call a mail script in such a way that is passes a string to the script itself.  This way in the notification's definition I can provide the sys_id of the KB article I want to insert.

1 ACCEPTED SOLUTION

Erik Gunther2
Kilo Guru

If using an event then refer to this article: https://community.servicenow.com/community?id=community_question&sys_id=b9b08765db98dbc01dcaf3231f96...

 

I did something a little different. I embedded an email script withing a notification and used a field on the notification's triggering record to populate my script. In the example below, I used this process to embed a custom date into an email.

 

Note: "current.scheduled_notification" is a field on the Notification Trigger table in the second screenshot (underlined in red).

find_real_file.png

 

find_real_file.png

 

 

 

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

It should be pretty easy. But depends on the way you are calling the notification. If you are calling the notification from a scheduled job, you must already be sending the object of the knowledge record.

 

I would just add ${text} to the notification body and it should work.


Please mark this response as correct or helpful if it assisted you with your question.

Matt Taylor - G
Giga Guru

You can't pass a parameter to a mail script like that, but if you are triggering the notification with an event, you can send the string as one of the event parameters and call that event parameter in the mail script. 

Erik Gunther2
Kilo Guru

If using an event then refer to this article: https://community.servicenow.com/community?id=community_question&sys_id=b9b08765db98dbc01dcaf3231f96...

 

I did something a little different. I embedded an email script withing a notification and used a field on the notification's triggering record to populate my script. In the example below, I used this process to embed a custom date into an email.

 

Note: "current.scheduled_notification" is a field on the Notification Trigger table in the second screenshot (underlined in red).

find_real_file.png

 

find_real_file.png