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

You can call a script include in a mail script.


Abhinay,



Am I calling it right?



Script Include:



var VariableScript = Class.create();


VariableScript.prototype = {


  initialize: function(list) {


  this.list = list;


  },


  createTable: function() {



  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] );



  }




  },


  list: [],


  type: 'VariableScript'


};



Email Notification:



<mail_script>




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


var allMandatory = a.allMandatory;


var missingMandatory = a.missingMandatory;




var b = new VariableScript();


b.createTable();




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




template.print(allMandatory [i] );




};




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




template.print(missingMandatory [i] );




};


</mail_script>


Abhinay Erra
Giga Sage

Yes that is correct. Which release are you on?


Geneva. Do you know a way to include the Message text and header and footer in the notification? When I change the Content Type to HTML and Plain Text it combines all the text and makes it look squished.