- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 07:27 AM
Hello,
For a requirement on a Catalog Item, I need to add the comments from an approval to the RITM description. I will post an image of the current flow and script below, but I am running into an issue.
The script works for the first few approvals, but for approvals 3-5, it pulls comments from previous approvals, not the current one.
Any help would be appreciated, thanks.
var appStatus;
var appApprover;
var appComments;
workflow.scratchpad.comments = '';
var app = new GlideRecord('sysapproval_approver'); app.addQuery('sysapproval', current.sys_id); app.query();
while(app.next()){
appStatus= "Approval Status: " + app.state + "\n";
appApprover= "Approver: "+
app.approver.getDisplayValue() + "\n";
appComments= app.comments.getJournalEntry(-1);
}
workflow.scratchpad.comments += appStatus;
workflow.scratchpad.comments += appApprover;
workflow.scratchpad.comments += appComments;
var comments = workflow.scratchpad.comments; current.description += comments;
var screquest = new GlideRecord('sc_request'); screquest.get(current.request);
screquest.description = desc;
screquest.update();
Solved! Go to Solution.
- Labels:
-
Notifications
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2019 08:48 PM
add orderByDesc in your query
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.orderByDesc('sys_updated_on');
app.query();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2019 08:48 PM
add orderByDesc in your query
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.orderByDesc('sys_updated_on');
app.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2019 10:08 AM
orderByDesc ended up only pulling the first list of comments, but I changed it to orderBy and it is pulling the last comment which is what I need. Thank you for pointing me in the right direction, you're a hero!