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
carramrodcarramrod 

Getting StandardControllerObject.LookupLink.Some Field

I'm trying to get the value of a field used in a lookuplink (User) on a VF page.

I know in other areas of salesforce you can use Parent.Child.FieldName format, but i'm getting an error when i try the following:

 

{!CustomObject.RequestedName__c.FirstName} 

RequestedName__c is the API name of the lookup link on the user object.

it gives the following error: Error: Unknown property 'String.FirstName'

If i take off FirstName it just provides the User ID for the User selected in the lookup link.

 

any help would be greatly appreciated.

sfdcfoxsfdcfox
When you want to go "through" a custom relationship, change the __c to __r (for relationship). You'll come out on the other side looking at the record that the field references. So, {!CustomObject__c.RequestedName__r.FirstName} should take you from your custom object, through the requested name field, and finally pluck the first name from the contact that it finds there. If you wanted a custom field on the object, use __c as normal: {!CustomObject__c.RequestedName__r.CustomContactField__c}.