You need to sign in to do that
Don't have an account?

Assign detail object to its master object
Hello I am writing a test calss and I need create a quote object for testing purpose. However, quote(Detail) has a master-detail relarionship with opportunity object (Master). There fore when I wrote "Quote.Opportunity.Id=Opportunity.ID", it reports "Deference a NULL value " Error. Is there anyone know why is this happening and how to fix it? Any help is appreciated.
Here are my codes:
Thank you!
Here are my codes:
Opportunity O = new Opportunity(); O.Name='sss'; O.AccountId=A.ID; O.LeadSource='Other'; O.Type='New Business'; O.CloseDate=myDate; O.StageName='Qualify'; O.CurrencyIsoCode='CAD'; Insert O; Quote Q=new Quote(); Q.Name='TestQuote'; Q.Status='Deaft'; Q.Payment_Terms__c='Payment Schedule'; Q.FOB__c='Our Shop'; Q.Freight__c='Collect'; Q.Lead_Time__c='TBA'; Q.Email='liam@shaverinc.com'; Q.ShippingState='ON'; Q.Opportunity.Id=O.Id; Insert Q;
Thank you!
Q.OpportunityId=O.Id;
Thank you,
Anil
All Answers
Q.OpportunityId=O.Id;
Thank you,
Anil