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

AccountContactRole and Account Relationship

Hi everyone,

I got this code:

List<String> Name = new LisT<String>();

List<AccountContactRole> listTemp = [Select Id,AccountID,Account.Name From AccountContactRole];

for(AccountContactRole acr : listTemp)





I got this error:

Invalid field Account.Name for AccountContactRole


Or in a visualpage if I want to access to this field I do:

<apex:column value="{!myVar.Account.Name}"/>

And it's working.

So How I can access to Name via Apex without doing a query again?



Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal
use this,