Ask For Approval

JamesLindsay
Giga Guru

I'm attempting to generate some number of approvals on a Requested Item where the Users, and the number of them, who need to provide approval, will vary with every run of the Catalog Item. I want all these users to have the approvals generated at the same time. Not serially where you have to wait for one to get the next approval request issued. If anyone on the list reject, the item is rejected. In the Flow that is triggered by the Service Catalog, I have gathered the sys_id of the user records into a comma separated list (string) as a Flow Variable. I have created a custom action that converts this list into a List of Records which, seems to be the only data type the Rules field accepts. For testing, these are valid/active users with at least the approver role. When the flow runs, none of the approvers are added and, the debug session shows Approval State "skipped" and I cannot figure out why. I cannot figure out why I get no approvers for the record in sysapproval_approver. I would like to use this method but, in attempt to make some progress, I removed that logic and replaced it with a GlideRecord script to insert the approvers in a for each item loop. All the approvals get created but, whether they approve or reject, the RITM is left with an Approval value of "requested" so, my Wait for Condition step waits. I'm not sure what else to try as I thought my initial attempt to use Ask for Approval, using an array of user sys_id, would work.

1 ACCEPTED SOLUTION

Gaurav Vaze
Kilo Sage

Hello @JamesLindsay 
I'm back with more simple solution of scripted approvals
Here is how you can simply achieve this

1] Create a flow variable:

create a simple string flow variable

2] set the flow variable (here we will split the list collector to array of sys id)

add the following code using toggle script

GauravVaze_0-1754631208392.png

var user_list= fd_data._1__get_catalog_variables.users.toString().split(',');
return user_list;

3]now add action as ask for approval

in the ask for approval, click on same toggle script and add following code

GauravVaze_1-1754631336606.png

var approvers = fd_data.flow_var.variable;
return "ApprovesRejectsAnyU["+approvers+"]";

 

This will work like magic

you can add if condition to update the ritm based on approval or rejection

 

for any more refernece of scripted approvals, visit the following link:

https://www.servicenow.com/community/workflow-automation-blogs/scripted-approvals-in-flow-designer-w...

 

Kindly mark this as helpful and accept this as solution if this helps

Thank you

Gaurav Vaze

Servicenow Developer

View solution in original post

17 REPLIES 17

BrianProvencher
Giga Guru

What sub flow are you triggering for the approvals?

It is the action step "Ask for Approval".

Are you using Catalog Builder? I ask because when we were migrating our old workflows to Flow Designer, I had to re-build our approval process to fit some specific business needs, like skipping approval if the requestor is the manager of the requested_for. 

No I am not but, you have given me another idea to try to use the Ask for Approval as a subflow and then pass it each sys_id in a for each loop.