function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MySetMySet 

Record retrieval Issue:

Hi -

I'm trying to retrieve Account phone number, Account Number from Contact. But I'm not able to.. Plzz help.

 

 

 List<Contact> conts = [SELECT ID, NAME, Account.Phone, Account.AccountNumber FROM CONTACT WHERE AccountId != NULL LIMIT 2];
   System.debug('$$$$$ CONTACTS ARE @@@@@@@' + conts[0]);

Best Answer chosen by Admin (Salesforce Developers) 
sambasamba

pls try this.

 

 List<Contact> conts = [SELECT ID, NAME, Account.Phone, Account.AccountNumber FROM CONTACT WHERE AccountId != NULL LIMIT 2];
   System.debug('$$$$$ CONTACTS ARE @@@@@@@' + conts[0].Account.Phone + ' ####' + conts[0].Account.AccountNumber);

 

 

If this post solves your problme please mark it as solution.

 

 

Thanks,

Samba

All Answers

sambasamba

pls try this.

 

 List<Contact> conts = [SELECT ID, NAME, Account.Phone, Account.AccountNumber FROM CONTACT WHERE AccountId != NULL LIMIT 2];
   System.debug('$$$$$ CONTACTS ARE @@@@@@@' + conts[0].Account.Phone + ' ####' + conts[0].Account.AccountNumber);

 

 

If this post solves your problme please mark it as solution.

 

 

Thanks,

Samba

This was selected as the best answer
MySetMySet

Thank you Samba.

 

-MySet