Notification Email script with parameters

ASA5
Kilo Sage

Hello ,

Can we use parameters when calling email script to do something like this   : ${mail_script:show_informations("first info","second info")} ?

Thank you !

11 REPLIES 11

Kalaiarasan Pus
Giga Sage

The script has access to the current object. Would this be sufficient for what you are looking to do?


sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Abdel,



You can wrap you code inside a function (in the email script).



Then call it with the parameters you need.



Example of email script:





  1. function generateTemplate(name, table){  
  2.  
  3.  
  4.   template.print("<p></p>" + name + ":<br />");  
  5.  
  6.  
  7.   var gr = new GlideRecord(table);  
  8.   gr.addQuery("request", current.sys_id);  
  9.   gr.query();  
  10.   while(gr.next()) {  
  11.     template.print(gr.number + ":   " + gr.cat_item.getDisplayValue() + ", Stage: " + gr.stage.getDisplayValue() + "<br />");  
  12.   }  
  13. }  

And then on your notification:





  1. ${mail_script:req_items}  
  2. <mail_script>  
  3.         generateTemplate("Requested items", "sc_req_item");  
  4. </mail_script>  


Regards,


Sachin


Hi Sachin,



it could be a nice solution but i have to use the mail script inside the href attribute of a link : <a href="link1?${mail_script:printParams("value1","value2")}">go</a>


with many links we will have a lot of <mail_script>.



Thanks,


This approach didn't worked for me.

 

I'll just do all of my custom logic inside of my mail_script, like Chuck mentions below, any custom parameters that should be needed can be retrieved via the event object or the current object being displayed. However, having the power to pass parameters directly to the mail script would had been cool. 😞