You need to sign in to do that
Don't have an account?
Yamile Pacheco Cueva
How to add a Save button that updates both the standard controller and the extension?
I have a page with a standard controller that calls an extension showing the child and grandchild records. I used this template to create my vf page https://success.salesforce.com/answers?id=90630000000hKccAAE (below) However, when I add a save button in the form, it only updates the fields in the object referenced in the standcard controller.
So, I added this code to my extension but it only updates the specific fields in that list
How can I save all fields in my standard controller AND in the fields I am calling from the extension?
Also, how can I go back to the detail page after saving? the "return null" brings me back to the visualforce page and I want it to go to the page where I have the button.
I am looking for the simplest answer here as I am not a developer.
Controller public with sharing class wrapperclass { private final Opportunity SiteO; public List<Account> accountList {get; set;} public List<Contact> contactList {get; set;} public wrapperclass (ApexPages.StandardController stdController) { SiteO = [SELECT Id, Name FROM Opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public List<Account> getAccounts() { if(accountList == null) { accountList = new List<Account>(); for(Account a: [select Id, Name from Account order by Name limit 10]) { accountList.add(a); } } return accountList; } public List<Contact> getContacts() { if(contactList == null) { contactList = new List<Contact>(); for(Contact c: [select Id, Name, Email, Phone from Contact order by Name limit 10]) { contactList.add(c); } } return contactList; } } Page <apex:page standardController="Opportunity" extensions="wrapperclass" showHeader="True"> <apex:form > <apex:pageBlock > <apex:outputText value="{!Opportunity.Name}"/> </apex:pageBlock> <apex:pageBlock > <!-- In our table we are displaying the cContact records --> <apex:pageBlockTable value="{!contacts}" var="c" id="table"> <apex:column value="{!c.Name}" /> <apex:column value="{!c.Email}" /> <apex:column value="{!c.Phone}" /> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock > <apex:pageBlockTable value="{!accounts}" var="a" id="table"> <apex:column value="{!a.Name}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
So, I added this code to my extension but it only updates the specific fields in that list
public PageReference saveAll() { update contactList; return null; }
How can I save all fields in my standard controller AND in the fields I am calling from the extension?
Also, how can I go back to the detail page after saving? the "return null" brings me back to the visualforce page and I want it to go to the page where I have the button.
I am looking for the simplest answer here as I am not a developer.