You need to sign in to do that
Don't have an account?
Pooja05
Calling approval process from the apex class
I am using the following code to submit request to the approval process
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setObjectId(quote.id);
However it doesnt trigger the approval process. (I mocked up data such that it meets the approval critieria.)
When I click on the submit for approval button on the related list ProcessSteps (Approval History) included in the VF page, it works fine. But the custom code above doesnt work.
Can you please help?
Thanks,
Pooja
All Answers
That just creates the request, you aslo need to start the process.
Approval.ProcessResult result = Approval.process(req1);
Then you can interrogate the result to make sure it submitted.
There is a full example of this in the Apex developers guide(page 296-297)
thanks.
It now works when the criteria is met but doesnt work when the criteria is not met.
Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.
An unexpected error has occurred. Your development organization has been notified.
Is there any way I can catch this error. Basically when the criteria is not met, an approval is not required. I just need to make the status auto approved.
I want to achieve the following
If no applicable process
then status = autoapproved.
Thanks,
Pooja