script to get approval rejection comment from sysapproval_approver table , in flow editor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2021 03:39 AM
Dear community leaders,
I have a custom record producer where i am using Flow designer for approval and rejection.
In case of rejection , comment is mandatory and same has to be reflect in my record producer.
I am using below script in my flow designer but not working, please help:
Approval :
Record producer:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2021 03:41 AM
Hi there,
"I am using below script in my flow designer but not working". Can you describe what's not working?
Also is your script a literal copy/paste? Asking because if I see something like this, this will never work:
apv .update();
Notice the space.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2021 06:08 AM
My script is not working , even approval won't triggered.
if i removed this script my flow is working and approval got triggered.
My requirement is to get the Rejection comment entered by approver into my record producer "Additional approval field".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2021 07:13 AM
can you share your flow is running on the record on which you want to update?
if yes then do this
var comments = [];
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',fd_data.trigger.current.sys_id).addOrCondition('document_id', fd_data.trigger.current.sys_id);
apv.addQuery('state', 'rejected');
apv.query();
while (apv.next()) {
// remove the timestamp and user information and just get the comments value
var comments = apv.comments.getJournalEntry(1).replace(dateRE, '');
comments.push(comments.toString());
}
return comments.toString();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2021 04:45 AM