My approval process has this criteria: Account: Account Name NOT EQUAL TO erwerwerwf and I have no issue putting an account into approval through Salesforce
yet when I run this code through anon Apex I get an error:
Account a = new Account(Name='abcdefg'); insert a; User user1 = [SELECT Id FROM User][0]; Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting request for approval.'); req1.setObjectId(a.id); req1.setSubmitterId(user1.Id) Approval.ProcessResult result = Approval.process(req1); System.debug(result.getInstanceStatus() + ' - ' +result.getInstanceStatus()); this is the error
System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []