You need to sign in to do that
Don't have an account?
Jonathan Meltzer 14
Lookup field populated but lookthrough is not working in APEX
I will try to generalize this question, as I believe that the issue is not related to the specific objects. I have an object (call it Object1) that has a Lookup field called Lookup1__c. The Lookup field looks to another object called Object2__c. Object2__c has an ID field and a custom field called Field2__c.
When I retrieve a record for Object1, I see a value in the Lookup1__c field - it is an ID. However, when I try to retrieve Object1.Lookup1__r.ID or Object1.Lookup1__r.Field2__c, all I get are NULL values. The query is not looking through to Object2, even though the relationship is valid and Developer Console does not show any errors.
Any ideas? How do I get the Object1.Lookup1__r.Field2__c value, once I am on the Object1 record?
When I retrieve a record for Object1, I see a value in the Lookup1__c field - it is an ID. However, when I try to retrieve Object1.Lookup1__r.ID or Object1.Lookup1__r.Field2__c, all I get are NULL values. The query is not looking through to Object2, even though the relationship is valid and Developer Console does not show any errors.
Any ideas? How do I get the Object1.Lookup1__r.Field2__c value, once I am on the Object1 record?
In case my guess is wrong, supply more information about what exactly you are doing and how. Share some code or even pseudo code for your scenario.
All Answers
In case my guess is wrong, supply more information about what exactly you are doing and how. Share some code or even pseudo code for your scenario.