- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
I'm working on the below flow in flow designer where I'm trying to retrieve some records in the 'sysapproval_approver' table:
I'm wanting to write the Name of the Approver field to the work notes of a record that gets created:
I'm using the below code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
this will work
var approvers = fd_data._3__look_up_records.records;
var ritmNumber = fd_data.subflow_inputs.ritm.number;
var workNotes = "RITM " + ritmNumber + " approved by:\n";
while (approvers.next()) {
var name = approvers.approver.getDisplayValue();
var date = approvers.sys_updated_on;
workNotes += "- " + name + " on " + date + "\n";
}
return workNotes;
OR Another way
1) you can create a flow variable of type String
2) then use "Set Flow Variables" flow logic to iterate over the approver records and store the details
3) then use this flow variable to set value in work notes
var ritmNumber = fd_data.subflow_inputs.ritm.number;
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', ritmNumber);
ritm.query();
ritm.next();
var workNotes = "RITM " + ritmNumber + " approved by:\n";
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', ritm.sys_id);
app.addQuery('state', 'approved');
app.query();
while (app.next()) {
var name = approvers.approver.getDisplayValue();
var date = approvers.sys_updated_on;
workNotes += "- " + name + " on " + date + "\n";
}
return workNotes;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello @matthew_hughes ,
Could you please share the complete requirements — specifically, which approvals are needed and on which table you want the work notes — so that I can test it in a PDI and provide an accurate solution?
Thank you!
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
I haven't tried it myself, but your script states var name = approvers[i].approver.display_value;
Try it with .getDisplayValue() and see what that returns, although it could already go wrong in the var approvers part. Put some logs in your script to see what you get for 'approvers'. I am wondering if that really is an array.
Personally, I would do a 'for each' on the look up records and set a flow variable to get everything in there and then add that variable to the work notes. You will be sure to do it for each records, without having to guess if your look up records is returning the records, or sysids or something else, making your for loop return nothing.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
this will work
var approvers = fd_data._3__look_up_records.records;
var ritmNumber = fd_data.subflow_inputs.ritm.number;
var workNotes = "RITM " + ritmNumber + " approved by:\n";
while (approvers.next()) {
var name = approvers.approver.getDisplayValue();
var date = approvers.sys_updated_on;
workNotes += "- " + name + " on " + date + "\n";
}
return workNotes;
OR Another way
1) you can create a flow variable of type String
2) then use "Set Flow Variables" flow logic to iterate over the approver records and store the details
3) then use this flow variable to set value in work notes
var ritmNumber = fd_data.subflow_inputs.ritm.number;
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', ritmNumber);
ritm.query();
ritm.next();
var workNotes = "RITM " + ritmNumber + " approved by:\n";
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', ritm.sys_id);
app.addQuery('state', 'approved');
app.query();
while (app.next()) {
var name = approvers.approver.getDisplayValue();
var date = approvers.sys_updated_on;
workNotes += "- " + name + " on " + date + "\n";
}
return workNotes;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @Ankur Bawiskar That works great thanks. However, it shows the date as:
2025-08-12 13:22:46
How do I update it so that it's shown as:
12-08-2025 13:22:46