Scenario is given below.

On Account, I have an approval process. and it's multistep approval. Let's assume its a 2 step approval. but in the approval steps, No approvers are mentioned. for the approvers, we are not having user lookups on Account but We have an Account Role object (Child of Account) from where approvers will be picked up dynamically based on the role (field on the object level) of the user.

Now suppose in the Account Role we have 3 users (3 records which contains user with the role) with the role Manager so in that case, approvers in the "first step" will be these 3 users and any of them can approve the record, and once approved the record will go in the next step to be approved.

Now I want to assign approvers dynamically in each step of the approval as explained in the above scenario.

Can I call the same defined approval in apex and then in apex set the approvers in different steps and fire the approval??

Any suggestions would be appreciated.



You can create lookup user fields in the account level and once the the user submit for approval, use field update (for example, set status to 'In Approval Process') and trigger will copied the relevant approvers from the related list to the account fields.

  • Thanks for the suggestions. but we dont want to use lookup fields bcuz It's not fixed that how many approvers will be there in the child Account Role. lets take the example - suppose step 1 is manager approver and step 2 is Sr Manager approvers. – vineet kumar Aug 20 '20 at 18:24
  • now suppose in Account Role We have 2 managers and 2 sr. manager so for Step 1 there will be 3 approvers (managers)and any of them can approve, once approved will go in step 2. and in step 2 there are 2 sr managers to approve and any of them can approve the record. so here there no fixed approver if it is fixed then why would we have Account Role, in that case, we can directly have 2 user lookup on account one for the manager and one for sr manager and the user can assign the values manually into the lookups – vineet kumar Aug 20 '20 at 18:34
  • Ok. Then you will probably need to customize the submit for approval little bit. Instead of using the standard submit button you will need some custom code that set the relevant approvers and submit it. See example- developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… For the next steps, you will need to do field update after each step (e.g Approval Status='Step 2') and trigger based on that will send it to the next approver – Liron C Aug 20 '20 at 18:37
  • Yes, you are right but in that case, it will be complete customization of approval, need to build a screen to Approve/Reject as well. I see there are concepts like ActorId something. don't know the complete picture, but its related to steps only. I was thinking if we can have a button Submit for Approval and call apex and then in the apex call the approval process and set the approvers in different steps of it but not sure if it's possible or not – vineet kumar Aug 20 '20 at 18:45

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