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

I hate to say it now it returns nothing     😞 .   I copied and pasted what you had into the workflow notification.   When I left off the <mail script> part it just printed the code as I would expect.   Thank you for trying to help--if you have any other ideas I am wide open to them.   Just in case this is what is in the code now



<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


      gs.log('Approver: ' + appr.approver.getDisplayValue() + '\n');


      gs.log('State: ' + appr.state) + '\n';


      gs.log('Comments: ' + notes + '\n');


      gs.log('\n');


  }


</mail_script>


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>


You are awesome thank you so much that worked like a champ


reginabautista
Kilo Sage

Awesome! Glad I could help