Email Scripts not Printing out template.print

kemmy1
Tera Guru

This script is getting attached to a notification off of the sysapproval_approver table.   I have 5 notifications that go out when the approval is rejected.   I only see one gs.info line in my logs (shouldn't I see 5?) and non of the template.print is on the email except the one out of the If statement (Approver that Rejected) that's showing up fine.  

Am I missing something?

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,/* Optional GlideRecord */ event) {

   

var gr = new GlideRecord('sysapproval_group');

      gr.addQuery('parent', 'current.sysapproval');

      gr.addNotNullQuery('approval_user');

      gr.query();

     

      if(gr.next()){

              gs.info("lisa parent: " + gr.parent);

              template.print('<p><font size="4" color="#808080" face="helvetica"><strong>');

              template.print('Rejection Details</strong></font><br><font size="3">');

              template.print('<b>Rejection Level:</b> ' + gr.wf_activity + '<br>');

              template.print('<b>Approval Group:</b> ' + gr.assignment_group + '<br>');

          }

     

      template.print('<b>Approver that Rejected: </b> ${approver}</font></font></p>');

                             

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

1 ACCEPTED SOLUTION

Nitesh Asthana1
Kilo Guru

Hi Lisa,



I just tested in my OOB instance, and below are my comments:



if(gr.next()){


              gs.info("lisa parent: " + gr.parent);                             //if you can see this in logs, it means if condition is being met


              template.print('<p><font size="4" color="#808080" face="helvetica"><strong>');         // This line was printed in the email


              template.print('Rejection Details</strong></font><br><font size="3">');     // This line was printed in the email as well


              template.print('<b>Rejection Level:</b> ' + gr.wf_activity + '<br>');   // This line was not printed in the email because I don't have gr.wf_activity field.when I removed gr.wf_activity, it got printed.


              template.print('<b>Approval Group:</b> ' + gr.assignment_group + '<br>'); //same as the 4th line


          }



Ensure if you are getting value of gr.wf_activity and gr.assignment_group (print their values in logs). Check logs if you get any error.


View solution in original post

4 REPLIES 4

Nitesh Asthana1
Kilo Guru

Hi Lisa,



I just tested in my OOB instance, and below are my comments:



if(gr.next()){


              gs.info("lisa parent: " + gr.parent);                             //if you can see this in logs, it means if condition is being met


              template.print('<p><font size="4" color="#808080" face="helvetica"><strong>');         // This line was printed in the email


              template.print('Rejection Details</strong></font><br><font size="3">');     // This line was printed in the email as well


              template.print('<b>Rejection Level:</b> ' + gr.wf_activity + '<br>');   // This line was not printed in the email because I don't have gr.wf_activity field.when I removed gr.wf_activity, it got printed.


              template.print('<b>Approval Group:</b> ' + gr.assignment_group + '<br>'); //same as the 4th line


          }



Ensure if you are getting value of gr.wf_activity and gr.assignment_group (print their values in logs). Check logs if you get any error.


Hmmmm that's weird. I don't see this in my email at all.   I do see my gs.info message in the logs (which means that the condition is met), but then in my email the only thing I see is the line AFTER the IF statement (template.print('<b>Approver that Rejected: </b> ${approver}</font></font></p>');).



I'm going to add it directly to my email and enclose it with <mail script> tags to see what happens.



Lisa


I see my problem now.   Those pesky apostrophe's that I have surrounding my current.sysapproval what causing me problems.   UGH.   SO PICKY!!  



Thanks so much Nitesh for your assistance!!



Lisa


Thanks Lisa.. Glad you got your issue resolved.


Gud day