how to fetch user name in approval activity in workflow?

sb171
Tera Contributor

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 ?

4 REPLIES 4

mdash
Giga Guru

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.

mdash_0-1669365879838.png

 

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

Nayan  Dhamane
Kilo Sage
Kilo Sage

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

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

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 ?

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.