You need to sign in to do that
Don't have an account?

Save Button Not Working
I created a visual force page with Account Details at the top and a contact related list at the bottom. I have Save and Cancel buttons on the page. The Save button works after I modify a contact but does not save the modification when I change one of the account fields. Here is my code.
---VF Page---
---VF Page---
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension"> <apex:form > <apex:pageMessages id="messages"/> <apex:pageBlock title="Account Penetration" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/> <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); } </Script> </apex:pageBlockButtons> <apex:pageBlockSection title="Contact Penetration" columns="3"> <apex:outputField value="{!account.Architect_Contacts__c}"/> <apex:outputField value="{!account.Design_Contacts__c}"/> <apex:outputField value="{!account.Total_Contacts__c}"/> <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/> <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/> <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/> <apex:outputField value="{!account.Architect_Penetration__c}"/> <apex:outputField value="{!account.Design_Penetration__c}"/> <apex:outputField value="{!account.Total_Penetration__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Specification Share of Wallet" columns="2"> <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/> <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/> <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/> <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/> <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/> <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Specification Win Rate" columns="1"> <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/> <apex:inputField value="{!account.Specifications_Won__c}"/> <apex:inputField value="{!account.Specifications_Lost__c}"/> <apex:outputField value="{!account.Specification_Win_Rate__c}"/> </apex:pageBlockSection> <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false"> <!-- There is a trick to creating a counter when rendering rows in a pageBlockTable. You have to define a variable to default to 0, and then update that variable inside the table row. This is the way that I can leverage smart row deletes --> <apex:variable var="rowNum" value="{!ZERO}" /> <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/> <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" > <apex:column headerValue="First Name"> <apex:inputField value="{!contact.FirstName}" /> </apex:column> <apex:column headerValue="Last Name"> <apex:inputField value="{!contact.LastName}" /> </apex:column> <!-- Add additional children metadata columns here --> <apex:column headerValue="Studio"> <apex:inputField value="{!contact.Studio__c}" /> </apex:column> <apex:column headerValue="Type"> <apex:inputField value="{!contact.Type__c}" /> </apex:column> <apex:column headerValue="Preferred Contact Frequency"> <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" /> </apex:column> <apex:column headerValue="Date Last Contacted"> <apex:inputField value="{!contact.Date_Last_Contacted__c}" /> </apex:column> <apex:column headerValue="Days Since Contact"> <apex:inputField value="{!contact.Days_Since_Contact__c}" /> </apex:column> <!-- This is the second half of the trick to keep track of your row index for deletion. --> <apex:variable var="rowNum" value="{!rowNum + 1}" /> <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true"> <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" /> </apex:commandLink> </apex:pageBlockTable> <!-- Want to specify immediate here and above so validation does not occur when you are trying to add/remove rows. Only want validation to occur when trying to save --> <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>Thanks!
Absolutely! I am going to put here the final code with the slight modification to the controller so that it redirects to the account.
VF:
Controller:
Now it should redirect back to the Account Detail page, unless you are specifically setting the saveUrl parameter on the custom button that redirects to the VF page.
All Answers
Would you mind sharing the class: EditableContactListExtension.
I have a feeling that the problem resides on the save() method on that class.
Thanks!
and on save(), you are updating contact and not account.
If you are including account also then pls share the code, it could be buggy.
Would you mind also sharing the "EditableList" class. The one you just shared extends EditableList, and it seems as though the code I believe might be the cause of this is on that other class.
I think that this code will fix your issue, but I want to make sure.
Thanks again! Here is the EditableList code.
Yep, its what I suspected. Try my code out. It should be saving the contacts first, and then save any changes to the Account.
I get the following error when I use your code. That is with correcting line 78 to super.save();
EditableContactListExtension: Non-virtual, non-abstract methods cannot be overriden: System.PageReference save()
Then do the following. Change the class "EditableContactListExtension" line 76 to this:
Then change the VF page on line 6 to this:
That should let you save and test out the changes.
Awesome. That fixed the saving issue but brought up a new one. This VF page is launched from a detail page button. Before when I hit save it took me back to the account detail page. Now it just stays on the VF page. Anyway to make it go back to the account detail page on save or cancel?
Absolutely! I am going to put here the final code with the slight modification to the controller so that it redirects to the account.
VF:
Controller:
Now it should redirect back to the Account Detail page, unless you are specifically setting the saveUrl parameter on the custom button that redirects to the VF page.
Thank you so much for your assistance. Everything is working perfect now!