0

My question could be a duplicate of another question that has been asked long back but without a concrete suggestion/solution.

Submitted user is also getting Reassign | Approve/Reject button on record

I have created multiple approvals through Apex and submitted as a non-admin user.

But, the biggest issue is, I am still able to see Reassign and Approve/Reject links for the approvals which I have submitted.

Actually, those approval requests have to be handled by the users Jon and Park in this case.

Any thoughts on why I am getting Reassign, Approve/Reject links even I am being as a submitter. I can adjust with Reassign link but I do not want Approve/Reject links which are not meaningful. Please see the screenshot below.

enter image description here

Experts, please advise. Thanks.

Code snippet:

            List<Id> approvers = new List<Id>{'005o0000000POyp','005o0000000POyo','005o00000033qPS','005o0000000POyn','005o0000001z4Qz','005o0000000P6Y0','005o0000000POyl','005o0000002mdGZ','005o0000000POzf','005o0000000PZSU','005o0000002H8kV','005o0000003ZFd0'};
            List<Approval.ProcessSubmitRequest> appreqs = new List<Approval.ProcessSubmitRequest>();

            for (Id appId : approvers) {
                Approval.ProcessSubmitRequest req = new 
                Approval.ProcessSubmitRequest();

                req.setComments('Need approval. Product sample quantity is beyond the limit.');
                req.setObjectId('006o000000GN07w');
                req.setNextApproverIds(new List<Id>{appId});

                appreqs.add(req);
            }

            List<Approval.ProcessResult> ApprovalReqs = Approval.process(appreqs);
  • did you logged in as integration user and taken this screenshot? – Santanu Boral May 22 '18 at 14:47
  • Yes, @SantanuBoral. I took this screenshot in sandbox. I logged in sys admin and logged in as integration user from Manage Users. – Bforce May 22 '18 at 14:54
1

Us the Approval set to Unanimous and not First Approver for Approvals for this section of the Approval process?

When multiple approvers are selected:

  • Approve or reject based on the FIRST response.
  • Require UNANIMOUS approval from all selected approvers.

If you look at the MetadataAPI for approval processes here, specifically the section on ApprovalStepApprover that would give you the reference you need. If you would like to modify the approval process from Apex you would need to download the one of the wsdl either developer or enterprise and then use the wsdl2apex tool in salesforce to generate a wrapper, or it would be easier to use Andy Fawcett's version of it where he already did most of the cleanup work.

  • Is that possible to set this through Apex? Because I have used apex to achieve multiple approvals as the standard point and click does not provide a way. – Bforce May 22 '18 at 14:57
  • are you creating the approvals via apex and the metadata or are you processing (i.e. submitting records for approval) through apex? – Gareth Jordan May 22 '18 at 17:14
  • i have created approvals via apex. The objective is the sales rep has to get approvals from respective product managers if their opportunity products exceeding the quantity limit. There could be many product managers for a product and a product can be managed by many prod managers and it is N-N relationship. Since, an opportunity can have multiple products, the approval request has to sent to many product managers for their approval. – Bforce May 22 '18 at 17:50
  • do u mind posting a snippet of code for how you create the approval process, cause i get the feeling that I'm talking around what you really mean. But if it is what you say then you need to set the ApprovalStepApprover.whenMultipleApprovers to RoutingType.FirstResponse because the default routing type is Unanimous – Gareth Jordan May 22 '18 at 18:35
  • please see the updated question as i have added the code snippet. – Bforce May 22 '18 at 19:44

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.