Rejection Comments in email not appearing

Troy S_
Kilo Expert

I have the following <mail_script>in my Workflow Notification:

<mail_script>  

  //get the related approvals for this change  

  //check for any reject and display comments  

 

  //create a new glide record query for approval records  

  var appr = new GlideRecord('sysapproval_approver');  

  //get approvals for this change  

  appr.addQuery('sysapproval',current.sys_id);  

  //get rejected approvals  

  appr.addQuery('state','rejected');  

  //execute the query  

  appr.query();  

 

  //process each result if there are any  

  if (appr.next()) {  

      //print the approval info to the email message  

      template.print('Approver: ' + appr.approver.getDisplayValue() + '\n');  

      template.print('State: ' + appr.state) + '\n';  

      template.print('Comments: ' + appr.comments + '\n');

      template.print('\n');  

  }  

</mail_script

It is returning the following:

        find_real_file.png

The field I am pulling in from is:

        find_real_file.png

Thank you in advance for your help on this issue.

Troy

1 ACCEPTED SOLUTION

reginabautista
Kilo Sage

Hi Troy try changing the gs.log to template.print   as below



<mail_script>


//get the related approvals for this change


  //check for any reject and display comments


var notes;


  //create a new glide record query for approval records


  var appr = new GlideRecord('sysapproval_approver');


  //get approvals for this change


  appr.addQuery('sysapproval',current.sys_id);


  //get rejected approvals


  appr.addQuery('state','rejected');


  //execute the query


  appr.query();



  //process each result if there are any


  while (appr.next()) {




    var je = new GlideRecord('sys_journal_field');


    je.addQuery('element_id', appr.sys_id);


je.addQuery('elements', 'comments');


je.addQuery('name', 'sysapproval_approver');


    je.query();


    if(je.next()){


          notes = je.value;


    }



      //print the approval info to the email message


template.print('Approver: ' + appr.approver.getDisplayValue() + '\n');


template.print('State: ' + appr.state) + '\n';


template.print('Comments: ' + notes + '\n');


template.print('\n');


  }


</mail_script>


View solution in original post

13 REPLIES 13

reginabautista
Kilo Sage

You need to loop thorugh the records..try changing code below


FROM



if (appr.next()) {



TO



while (appr.next()) {


I changed it to


        while (appr.next()) {



However it still returned the same response that I got above.


        find_real_file.png


ankit_sharma487
Kilo Guru

try with changing if (appr.next()) to While (appr.next()). it will execute till you have matching records and IF will do for once only


That did not work, same results