Sample of using script include in email notification

javis
Giga Expert

Hi everyone,

I need help with calling a script include into an email notification. I am looping over the email body and if there are mandatory variables missing in the email then a notification gets sent to the user. I am able to get the missing/mandatory variables but can not format the question neatly in the email notification. Any help would be greatly appreciated.

11 REPLIES 11

Abhinay Erra
Giga Sage

If this on geneva, then the syntax for mail script is in correct. <mail_script> tags are legacy ones. You will need to create a script under notification email scripts and reference that in the actual notification as ${mail_script:script_name}


Scripting for email notifications


abhinay,



Here is my Email Script Notification:



Name is array_table



(function runMailScript(current, template, email, email_action, event) {



  var a = JSON.parse(event.parm2);


  var allMandatory = a.allMandatory;


  var missingMandatory = a.missingMandatory;



  for (var i = 0; i < allMandatory.length; i++) {



  template.print(allMandatory[i]);



  }



  for ( i = 0; i < missingMandatory.length; i++) {



  template.print(missingMandatory [i] );



  }




})(current, template, email, email_action, event);



And here is my notification calling it:



${mail_script:script_array_table}



I'm getting the error: 'Email script render error: email script [ script_array_table ] does not exist'


James,



You are calling


${mail_script:script_array_table}



But your post says the script is named 'array_table'.   Should you not be calling


${mail_script:array_table}



ps - I came here because I'm having a similar error. I'm trying to include the out-of-box script for listing attachments named 'attach_links'.
That script is in the global scope. My calling notification is in a scoped application. I don't know if that is the issue. I'm investigating now.


Good catch. James update your mail script tag accordingly.


FYI, I duplicated the out-of-box attach_links as a new Email Script in our scoped application scope and renamed it u.attach_links.


Calling ${mail_script:u.attach_links} still throws an error: 'Email script render error: email script [ u.attach_links ] does not exist'.



Stumped. It definitely exists.