Skip to main content
Daniel Marcus (Intelex) 님이 #Data Management에 질문했습니다
Hi All,

 

I'm getting a null value on a lookup field when running a test class.

 

 

Account a = new Account(Name = '1', Owner = u, CurrencyIsoCode = 'CAD');

insert a;

a = [SELECT id, AccountNumber, Name, CurrencyIsoCode, Related_Billing_Contract__c FROM account WHERE id = :a.id];

Billing_Contract__c bc = new Billing_Contract__c(Account__c = a.id, Active__c = TRUE, Annual_Increase_Amount__c = 0.03, Billing_Frequency__c = 'Annually');

insert bc;

bc = [SELECT id FROM Billing_Contract__c WHERE id = :bc.id];

a.Related_Billing_Contract__c = bc.id;

update a;

a = [SELECT id, AccountNumber, Name, CurrencyIsoCode, Related_Billing_Contract__c FROM account WHERE id = :a.id];

System.debug('Related_Billing_Contract__c: ' + a.Related_Billing_Contract__c);

Opportunity o = new Opportunity(Name = '2', GSS_Rep__c = g.id, Account = a, StageName = 'No Status', CloseDate = System.today(), Amount = 1, Type = 'New Implementation', License_Model__c = 'Perpetual', Owner = u, Sales_Rep2__c = s.id, Pricebook2Id = p.id, CurrencyIsoCode = 'CAD', Intall_Date_Opp__c = system.today(), Milestone_Trigger__c = 'Installation', Payment_Terms_Drop__c = '30 Days on Order');

insert o;

o = [SELECT id, AccountId, Account.AccountNumber, Account.Related_Billing_Contract__c, Account.Name, Name, Service_Value_No_Milesotne__c, CurrencyIsoCode, Software_Value_No_Milestone__c, Account.Id, Account.Licensing_Model__c, type, Service_Days__c FROM opportunity WHERE id = :o.id];

System.debug('o.account.Related_Billing_Contract__c: ' + o.Account.Related_Billing_Contract__c);

 

My initial Debug returns an ID for the Account.Related_Billing_Contract__c, but when I go through the Opportunity to find the same value (Opportunity.Account.Related_Billing_Contract__c) I am getting NULL returned. Any help?

 

 
답변 2개
  1. 2015년 5월 12일 오후 2:24
    Hello Daniel,

     

    This community is focused on help with configuration changes and non-programmatic solutions.  You have a better chance of getting this issue resolved if you post it on one of the following forums:

     

     

    For any configuration changes and point and click design solutions, feel free to post in this community and we will be glad to help you out.