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
Andrew McAllisterAndrew McAllister 

Get the account name from the ID

I'm very new to lightning components and also development in general...

I'm working on creating a lightning component that displays Account Partners. I am getting a list of AccountPartner records and want to display the account names instead of the ID from AccountToId field. 

Is there a way to get and display the name of the account without running another SOQL query?
 
<aura:iteration items="{!v.partners}" var="partner">

<-- This is working, but only shows Id-->
{! partner.AccountToId}


<!-- Doesn't work...
{! partner.AccountToId.Name} -->


 </aura:iteration>


Hope this makes sense.


Thanks
Best Answer chosen by Andrew McAllister
Alain CabonAlain Cabon
What is your query?

SELECT Partner.AccountTo.Name From Partner WHERE AccountFrom.Id = Case.AccountId LIMIT 1
https://success.salesforce.com/answers?id=9063A000000e80kQAA
 

All Answers

Alain CabonAlain Cabon
And just ?

{! partner.AccountTo.Name} 
Andrew McAllisterAndrew McAllister
@Alain - thanks for the response. No luck with that, though.
Alain CabonAlain Cabon
What is your query?

SELECT Partner.AccountTo.Name From Partner WHERE AccountFrom.Id = Case.AccountId LIMIT 1
https://success.salesforce.com/answers?id=9063A000000e80kQAA
 
This was selected as the best answer
Alain CabonAlain Cabon
sfdcfox is him (number one): https://salesforce.meta.stackexchange.com/users

Or also here:

Select AccountTo.Name, AccountFrom.Name, Role From Partner Where 
https://developer.salesforce.com/forums/?id=906F000000092LzIAI
Andrew McAllisterAndrew McAllister
Thank you Alain.  It's working now... I did not have AccountTo.Name in the Select clause of my query. After adding that it worked.  Thanks again for your help!