You need to sign in to do that
Don't have an account?
sctdev
Reference to an object
I have a reference Id from a query of an object to reference another object. How can I use this reference id to either look up the record or directly access the record?
SCT
for (myContact__c c : [Select Id, Name, Email_Recipient__c Where Name like :contactName Limit 1]) { ); recipId = c.Email_Recipient__c; } insert newC_Report; } catch (System.Exception e) { System.debug('Error: ' + e); }
Email_Recipient__c is a reference to another object with a field for email address, so I need to access the email address with the recipId from above.
In Apex explorer it looks like:
Email_Recipeint__c - reference(18)
- Email_Recipient__r
- Email_address__c
To get to the email address, use the below in your SOQL:
Email_Recipient__r.Email_address__c
I was making it harder than it was.
Thanks,