How to get the last updated comment from any approval record

suprakash
Giga Expert

How to get the last updated comment from any approval record. i am using this code but its not working perfectly. Some time its displaying sometime not. i tried it using background script

---------------code--------------------------------------------

    var ab= new GlideRecord('sysapproval_approver');

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

  ab.query();

  ab.next();

  //gs.print(ab.state);

  var notes = ab.comments.getJournalEntry(1);

  var na = notes.split("\n\n");

  for (var i = 0; i < na.length-1; i++)

  template.print(na);

1 ACCEPTED SOLUTION

If you have multiple approvals on your requested item, you should loop and check it. I believe this code is written on sc_req_item table. Try this and see if it log comments



var ab = new GlideRecord('sysapproval_approver');


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


ab.query();


while(ab.next()){


  var notes = ab.comments.getJournalEntry(1);


  gs.log(notes, "COMMENTS");


}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

5 REPLIES 5

Thanks a lot