You need to sign in to do that
Don't have an account?
David Leckenby
Saving Opportunity and related Contact from single Visualforce page
I have created a visualforce page that displays both opportunity and contact fields that I want users to be able to edit and save. I am using the opporutnity standard controller and added the following extension so as to be able to override (or add to) the standard save functionality with the 'SaveBoth' method (below). I have managed to be able to query the correct contact and populate the contact ID, but upon 'Save' none of the contact fields on the Visualforce page are updating.
public with sharing class NewLeadControllerExtension { ApexPages.StandardController controller; public Opportunity oppt {get; set;} public Account acct {get; set;} public Contact cont {get; set;} public NewLeadControllerExtension(ApexPages.StandardController controller) { this.controller = controller; oppt = (Opportunity)controller.getRecord(); acct = new Account(); cont = new Contact(); acct.Name = oppt.Account.Name; cont.Id = [SELECT Id FROM Contact WHERE Name =: acct.Name LIMIT 1].Id; } public String getTitle() { return 'The Contact ID is '+ cont.Id; } public PageReference SaveBoth() { update cont; controller.Save(); return null; } }
As i can see you are using SaveBoth as PageReference which is returning null. You can use void instead .
I suspect you should not be rerendering the page after the SaveBoth method completes .
Try rerendering the area once the SaveBoth method completes its operations and it should work fine. Else you can post your vf page code here.