- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:31 AM
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:34 AM
Hi,
var notes = ab.comments.getJournalEntry(1); should give you last update comments. Why are you looping it again?
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:40 AM
I tried but its not giving on the way you suggested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:41 AM
may be there are approvals for my requested item that's why its getting confused
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:45 AM
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