flow designer approval

El Cuchi
Tera Guru

Hi All,

 

I am moving a workflow to flow designer but i am having some issues. Hence, your help will be appreciated it.

 

1 - in my workflow i request approval to more than a group. one is fixed and the others are based on the business application selected. I managed to add approvals, but one user from a group approves, others from same group are not set to "no longer required' and it completes the request without waiting for the rest of the groups to approve.

I need for one person for each group to approve.
here is my script
var answer = [];
var approvers = 'a7923e8edbe429103985be43f3961941';

//search for managed by group of business applications
var app = fd_data.trigger.request_item.variables.business_applications_affected.toString();
    //search for application managed by group
    var gr = new GlideRecord('cmdb_ci_business_app');
    gr.addQuery('sys_id','IN', app);
    gr.query();
    while(gr.next()){
        if(gr.managed_by_group!=''){
            approvers=approvers+','+gr.managed_by_group;
        } else {
            if(gr.managed_by_group=='') {
               approvers=approvers+','+gr.application_manager;
            }
        }
    }
//}
return "ApprovesAnyG["+approvers+"]OrRejectsAnyU["+approvers+]";
 
why?
 
2 - in the workflow i have a "run script" activity. how do i do the same in flow designer?
my script inspect a variable and then searches in the business application table. When found it set a specific field to true.
 
regards,
max
 
7 REPLIES 7

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @El Cuchi 
for easy approach and complexity, you didnt need to write the script for the approvals in flow designer, as it is handling easily without code.

Add a Action ---> Ask for Approval
Click on Group icon and select your both groups. 
Done 

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma

Hi Deepak,

when u look at the script you can see that the name of the groups are not fixed. Hence, your option won't work.

regards,

Max

Deepak Shaerma
Kilo Sage
Kilo Sage

HI @El Cuchi 

Got your point, for this requirement just create a new Action and Add Inputs that your script would need (for example, business_applications_affected).

DeepakShaerma_0-1719891872790.png

In the Outputs section, define the output variable like approvers.

 

(function execute(inputs, outputs) {
    var answer = [];
    var approvers = 'a7923e8edbe429103985be43f3961941';

    var app = inputs.business_applications_affected.toString();
    var gr = new GlideRecord('cmdb_ci_business_app');
    gr.addQuery('sys_id', app);
    gr.query();

    while (gr.next()) {
        if (gr.managed_by_group != '') {
            approvers += ',' + gr.managed_by_group;
        } else if (gr.managed_by_group == '') {
            approvers += ',' + gr.application_manager;
        }
    }

    outputs.approvers = approvers;
})(inputs, outputs);

 

 Save and publish your action.

2. Use the Custom Action in Your Flow:
a. In your flow, add the custom action you created.
b. Provide the necessary inputs.
c. Capture the output approvers list provided by the custom action.
d. Use the Create Record action to create approval records for each group appropriately.

 

var approversArray = approvers.split(',');

approversArray.forEach(function(approver) {
    var approvalRec = new GlideRecord('sysapproval_approver');
    approvalRec.initialize();
    approvalRec.approver = approver;
    approvalRec.sysapproval = flow.variables.ritm; //Assuming ritm is an input variable to the flow
    approvalRec.insert();
});

 

 

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma 

hi Deepak,

thx for the tip. i dont find any custom action as u described. would u pls provide more details?

regards,

max