- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month 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
a month 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
a month ago
Glad to know that my script worked.
Please mark my response as correct and close the thread as I answered your original question.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
you can convert that date format using GlideDateTime
check these links and enhance your script
Convert format of glidedatetime from YYYY-MM-DD to YYYY-MMM-DD
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