4

We have a requirement where certain approvers need to approve a record. However the expectation is to avoid a delay in the approvals so that certain approvers can approve the record in parallel rather than sequential.

So the refined version is to bunch multiple approvers together in a single step(to achieve parallel approval) & there would be a number of such steps(sequential approval). However all the approvers in a single should approve it before it goes to next level.

We can define the entry criteria at each step level. However the issue is these approval steps depend upon the certain entry criteria (currently determined on a record & tracked as a flag) & all the approvals in a single step may not be required for a specific record.

Any help would be greatly appreciated.

Thanks.

1

You will have to assign this to a queue instead of an approver... this is how I accomplished in a trigger

//Retrieve the queue
            List<Group> queue = [SELECT Name, RelatedId
                                FROM Group
                                WHERE Type = 'Queue'];

//This var will contain the group Id
String s = '';
for(Group g : queue)
     if(g.Name == 'Supervisor ADI'){
        s = g.Id; break;
     }else if(validate another queue){

     }
         if(s != ''){

                        Approval.ProcessSubmitRequest req = new     Approval.ProcessSubmitRequest();
                        req.setComments(MENSAJE_15);
                        req.setObjectId(sd.Id);
                        req.setNextApproverIds(new Id[]{s});
                        requestList.add(req);
                    }
}
0

I wrote a tutorial on using an Apex trigger to Dynamically assign an approval that might be helpful for you

essentially, you must create a custom field on the object you want to be approved, then use an initial submission action on your approval process to modify that field.

Because the initial submitting action fires before the record is locked, it will allow the trigger to run apex code to set a special field on the record owner's user record.

That field can then be used for the approver.

enter image description here

Sounds complicated but it's really not. See the link below for full code samples as well as a video showing step by step how to set this up. There is code for a full working example. The solution is mostly config plus some simple trigger logic.

CodeByCody -
Use Apex Code to Dynamically Select the Approver in a Salesforce Approval Process

1
  • 1
    Can you please you essential part of tutorial in this post because this link may be expire in future this is not recommend ..
    – Ratan Paul
    May 9 '16 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.