I am trying to write a test class for an email controller but keep getting tripped up on the Approval Process part. The long & short of it is that my approval processes for SBQQ__Quote__c in my org reference formula fields on Quote from the related SBQQ__SalesRep__c(User) record. I have inserted a test user and a test user as manager. I have all fields on their records referenced by the formulas on SBQQ__Quote__c populated but am still gettiing null values and my process keeps crashing with the error

"FATAL_ERROR System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []"

I know I am setting everything correctly and really believe this is a matter of the formula fields not populating after the testQuote record is inserted in my test class. I am also re-querying for the record and debugging does indeed show my ID's match and everything is correct, just no populate formula field values. Does anybody know any other tricks to make formula fields with values from related objects populate in a test class?

I cannot post my entire code block but here are the snippets of relevance:

User testUser = new User();
        testUser.FirstName = 'Test';
        testUser.LastName = 'User';
        testUser.formulaField1 = 'test'; // formula field 1 needed on Quote
        testUser.formulaField2 = 'test'; // formula field 2 needed on Quote
        testUser.Username = '[email protected]';
        testUser.Email = '[email protected]';
        testUser.Alias = 'user';
        testUser.TimeZoneSidKey = 'America/Los_Angeles';
        testUser.LocaleSidKey = 'en_US';
        testUser.EmailEncodingKey = 'ISO-8859-1';
        testUser.ProfileId = [SELECT Id From Profile Where Name='System Administrator'].Id;
        testUser.LanguageLocaleKey = 'en_US';
        insert testUser;

        System.debug('testUser.formulaField1__c: ' + testUser.formulaField1__c); // both of these values populate correctly to be passed down to quote after setting this user as SBQQ__SalesRep__c.
        System.debug('testUser.formulaField2__c: ' + testUser.formulaField2__c);

SBQQ__Quote__c testQuote = new SBQQ__Quote__c();

        testQuote.SBQQ__Account__c = testAccount.Id;
        testQuote.SBQQ__Opportunity2__c = testOpp.Id;
        testQuote.SBQQ__Status__c = 'In Review';
        testQuote.Quote_Name__c = 'Test Quote';
        testQuote.Health_Score__c = 5;
        testQuote.SBQQ__SalesRep__c = testUser.Id;

        insert testQuote;
        System.debug('testQuote.formulaField1__c: ' + testQuote.formulaField1__c); // formula field 1 required by my approval process, returns null
        System.debug('testQuote.formulaField2__c: ' + testQuote.formulaField2__c); // formula field 2 required by my approval process, returns null
        System.debug('testUser.Id: ' + testUser.Id);
        System.debug('testQuote.SBQQ__SalesRep__c' + testQuote.SalesRep__c // this ID matches above line so I am getting the right user record, the formula just isn't populating

The two user fields, formulaField1 and formulaField2, are supposed to be referenced by formula fields on SBQQ__Quote__c and then used in my Approval Process, but they aren't populating.

I am also trying to implement solutions I have googled already:

Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();


Approval.ProcessResult result = Approval.process(req);

Nothing seems to work, just keep getting "FATAL_ERROR System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []"

1 Answer 1



I had to update the testUser record again with the same field values defined on insert after inserting testQuote, then the formula fields on Quote populated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .