Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Identify If a User Is an Approver in Workflow and Flow Designer.

anandcristy
Kilo Contributor

Hi,

I have requirement, Need to replace the user with new user for the approval part. Need script for how many catalog workflow and flow a user is the approver. How to find?

Thanks.

1 REPLY 1

Musab Rasheed
Tera Sage

If I'm not wrong, for every approval in Workflow/flow designer it creates entry in Approval table, you can write fix script to see count and replace it accordingly no ?

var approverSysId = 'PUT_USER_SYS_ID_HERE';
var ga = new GlideAggregate('sysapproval_approver');
ga.addQuery('approver', approverSysId);
ga.addQuery('state', 'requested');
ga.addAggregate('COUNT');
ga.query();

if (ga.next()) {
  var totalCount = ga.getAggregate('COUNT');
  gs.info('Total Approval Records for User: ' + totalCount);
}
Please hit like and mark my response as correct if that helps
Regards,
Musab