What to do when I receive - no applicable approval process was found?

1.3K    Asked by Aalapprabhakaran in Salesforce , Asked on Apr 28, 2023
// Insert an account Account a = new Account(Name='Test', annualRevenue=100.0); insert a; // Create an approval request for the account Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setObjectId(a.id); req1.setNextApproverIds(new Id[] {'***************'}); // Submit the approval request for the account Approval.ProcessResult result = Approval.process(req1);

Am trying to execute this code in an anonymous block. However when I tried to trigger it I got the same error all the time. Hard coded next approvers ID. No luck.

Any suggestions on what I am doing wrong ?

Answered by Ranjana Admin

I think there is a problem with profile permissions which is why you are receiving - no applicable approval process was found. Try with this code:

Account acc1 = new Account(Name='acc1'); insert acc1 if([select count() from ProcessInstance where targetobjectid=:acc1.id] < 1 xss=removed xss=removed>

Your Answer