You can also display data from related records. For example, while viewing the object details for Account, you might have noticed that the Account object has a field called Account Owner, and that its type is Lookup(User). In other words, this field has a relationship to a User record. By clicking the Account Owner field label link, you’ll discover its Field Name is Owner.
The Owner relationship represents a User. And, if you click
, you’ll find that User has a Name field. Let’s use this information to display it.- Modify accountDisplay to include this field by adding the following paragraph after the existing one:
<p>Here's the owner of this account: {! account.Owner.Name}</p>
The “dot notation” (account.Owner.Name) indicates that you want to traverse the relationship between the records. You know that account.Owner indicates the Owner field of the account record. The extra name at the end indicates that the owner field isn’t a simple field representing a String, but a relationship to another record (it’s a Lookup(User)), and that you’d like to get the record represented by the value of the Owner field (it’s a User record), and display the Name field on that record.
Shouldnt {! myobject__c.foo__c} actually be {! myobject__r.foo__c}. signifying the relationship name?
ReplyDelete