Can we pass parameters to email scripts from email template

Susmitha14
Tera Contributor

Hi,

I want to create a mail script and it should be called from email template. How can I achieve getting different outputs from same mail script dynamically. Can we achieve this by passing through any parameters in the email scripts. Is there any mechanism to pass parameters to mail script from email template. At present for every variable I am creating a unique mail script to get the value Is there any way to get the variables dynamically from a single mail script i.e called from email template.

1 ACCEPTED SOLUTION

Hi,

You cannot pass any parameter etc to email script unless you are triggering the notification via eventQueue

3rd or 4th parameter you can use to send some data

gs.eventQueue('event_name', obj, 'my-data','');

Then access the data in email script using event.parm1

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Hi,

You can use same email script with different content based on the notification from which it is getting called.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

Can you explain it with an example code.

Hi,

For your question you cannot pass any parameter to email script from email template.

If you wish to use same email script in different notifications and want to print different content then I have shared the sample script above

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

So, There is no possibility to get different output variables from a single mail script dynamically i.e called in email template used in the same notification. 

Hi,

You cannot pass any parameter etc to email script unless you are triggering the notification via eventQueue

3rd or 4th parameter you can use to send some data

gs.eventQueue('event_name', obj, 'my-data','');

Then access the data in email script using event.parm1

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader