how to fetch user name in approval activity in workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 11:39 PM
Is there any way we can replace the approval user in workflow using script ?
or if there is any table where the approval user data is stored ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 12:45 AM
Hi,
It is a little difficult to understand the exact requirement, but you can definitely user script to insert group, user approvals, validate approval status, etc.
The table that stores approval is : sysapproval_approver. Here is a screenshot of how the approval record looks like:
Please note: at the bottom, you will find the summary of the record being approved.
You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 01:03 AM
Hello @sb171 ,
We cannot make the changes in workflow once it is triggered for the existing request. you can make the required changes for the items to be raised later.
Regarding changing the approver you can use the below code to update the approver:
var elep = new GlideRecord('sysapproval_approver');
elep.addQuery('sys_id','sys id of record on table');
elep.query();
if (elep.next())
{
elep.approver='sys id of new approver';
elep.setWorkflow(false);
elep.autoSysFields(false);
elep.update();
}
Please mark my response as Correct / Helpful based on Impact.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 09:06 AM
Thanks for your help , can you let me know if i want to throw it to 2 approvals how can i do that , here
elep.approver='sys id of new approver';
More than one sys_id ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 10:47 AM
Hello,
Can you explain a little more what do you mean by 2 approvals as the approver field is a reference it can only store one value. If you could attach couple of screenshots it would be easier to assist you.
Thanks.