Retrieving fields when a lookup is populated

When viewing an sObject that has a lookup relationship to another sObject, additional fields from the related sObject can be displayed on the page using formula fields. When creating a new record, or editing an existing record and changing the lookup value, formula fields cannot be used, as the lookup field has only been populated with a record ID and the related record has not been retrieved.

In this recipe, we will create a Visualforce page that allows a user to create a case sObject record. The case standard controller and a controller extension manage the new case record. When the lookup to the account that the case is related to is populated, additional fields are retrieved from the account record ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.