Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

This is the way:

        Account acc1 = new Account(Name='acc1');
        insert acc1

        if([select count() from ProcessInstance where targetobjectid=:acc1.id] < 1)
        {       
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Approve.');
            req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
            req.setObjectId(acc1.Id);

            //Submit the approval request
            Approval.ProcessResult result = Approval.process(req);

        }

Copied from: NO_APPLICABLE_PROCESS :No applicable process found!NO_APPLICABLE_PROCESS :No applicable process found!

This is the way:

        Account acc1 = new Account(Name='acc1');
        insert acc1

        if([select count() from ProcessInstance where targetobjectid=:acc1.id] < 1)
        {       
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Approve.');
            req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
            req.setObjectId(acc1.Id);

            //Submit the approval request
            Approval.ProcessResult result = Approval.process(req);

        }

Copied from: NO_APPLICABLE_PROCESS :No applicable process found!

This is the way:

        Account acc1 = new Account(Name='acc1');
        insert acc1

        if([select count() from ProcessInstance where targetobjectid=:acc1.id] < 1)
        {       
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Approve.');
            req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
            req.setObjectId(acc1.Id);

            //Submit the approval request
            Approval.ProcessResult result = Approval.process(req);

        }

Copied from: NO_APPLICABLE_PROCESS :No applicable process found!

Source Link
Ashwani
  • 22.7k
  • 4
  • 41
  • 73

This is the way:

        Account acc1 = new Account(Name='acc1');
        insert acc1

        if([select count() from ProcessInstance where targetobjectid=:acc1.id] < 1)
        {       
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Approve.');
            req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
            req.setObjectId(acc1.Id);

            //Submit the approval request
            Approval.ProcessResult result = Approval.process(req);

        }

Copied from: NO_APPLICABLE_PROCESS :No applicable process found!