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
Karthik TathiReddyKarthik TathiReddy 

Not saving lookup field value in visualforce page

Hi,

I created a visualforce standardcontroller page with extension controller.

Here I used Opportunity as the parent object and another custom object as child to the opportunity.

In the custom object I have a look up field. Whiile give the field values of custom object in visualforce page and saving it, It is not saving the value of lookup field.

The sample code in visualforce page is shown below.

Page:

<apex:inputField value="{!Opportunity.ChildObject__r.name}">

<apex:inputField value="{!Opportunity.ChildObject__r.email__c}">

<apex:inputField value="{!Opportunity.ChildObject__r.Contact__c}">(this is the lookup field)

<apex:commandButton value="Save" action="{!Save}">

Here after clicking the save button the contact lookup field is not saving...

Can you reply me how to get save the lookup field.

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The standard controller will only save the record that it is managing - in this case the opportunity.  If you want to save related records, you'll have to take care of that in your extension controller.

All Answers

bob_buzzardbob_buzzard

The standard controller will only save the record that it is managing - in this case the opportunity.  If you want to save related records, you'll have to take care of that in your extension controller.

This was selected as the best answer
Karthik TathiReddyKarthik TathiReddy

Thank you bob_buzzard.