+ Start a Discussion

error validating test code: Business Id ... is missing or invalid?



I'm having an odd issue with test code for a trigger.  In short, I want to insert an Opportunity, then update that same Opportunity with one changed field.  Snippet of code is below...


        Account acct1 = new Account(Name = 'opptriggertestacctname');
        insert acct1;
        Opportunity opp1 = new Opportunity(Name = 'opptriggertest_oppname1'
                                            , AccountId = acct1.Id
                                            , StageName = 'stage1'
                                            , CloseDate = Date.today()
                                            , Type_Of_Sale__c = 'Exclusive'
                                            , Authorized_Initials__c = 'cm');
        insert opp1 ;


         Opportunity retOpp = [SELECT Id
             FROM Opportunity WHERE Id = :opp1.Id LIMIT 1];
         retOpp.StageName = 'Closed Won';
         update retOpp;        



Error: DmlException: Update failed: First exception on row 0 with id 006...; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Business ID for ... is missing or invalid.


Gives me a line number - it's the line where i'm attempting to do the update.


I don't have any validation rule that matches that message.  What is Business ID?  One additional note: if I remove the retOpp.StageName = 'Closed Won'; line - and just do the update, it doesn't fail.  (But then it doesn't provide any coverage...)


Any help is greatly appreciated.  I've never had this issue before...






Best Answer chosen by Admin (Salesforce Developers) 

got it -my fault.  i was looking for Business Id on Opportunity, but it was actually on Account.