0

I have a problem in my ORG, Whe I excute my Test Class I receive this error bellow :

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AVA_SFCORE.OppTriggers: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.AVA_SFCORE.OppTriggers: line 17, column 1: []

I have Avalara application to calculate taxes, and ther is a trigger which block my Clas when then the test try to create an opportunity or a Quote.

I can't neither launch my Test class and deployement.

This is my Test Class :

@isTest
private class TestQuoteAutoSync {
    static testMethod void insertQuote() {

        Opportunity opp = new Opportunity();
        opp.Name = 'Test Opportunity';
        opp.StageName = 'Prospecting';
        opp.CloseDate = system.today();
        insert opp;

        Quote quo = new Quote();
        quo.Name = 'Test Quote';
        quo.OpportunityId = opp.Id;

        Test.startTest();
        insert quo;
        Test.stopTest();

        Opportunity o = [select SyncedQuoteId from opportunity where id = :opp.Id];
        system.assert(o.SyncedQuoteId != null);

    }
}

How can I resolve this issue Thank you.

0

Most likely, it's crashing because it expects the Opportunity to have an Account.

Account accountRecord = new Account(Name='Test');
insert accountRecord;
Opportunity opp = new Opportunity();
opp.Name = 'Test Opportunity';
opp.AccountId = accountRecord.Id;
opp.StageName = 'Prospecting';
opp.CloseDate = system.today();
insert opp;

The Account field is required in Salesforce, so they probably didn't check to see if this field was null before trying to do whatever logic it is trying to do.

1
  • Thank you for your answer, I still have the same error. I think I have trriger linked to managed app and he launched before insertion of the Opportunity. – Elymaz Dec 14 '20 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.