You need to sign in to do that
Don't have an account?
tobias.brand
Custom Save button not saving on related list
Hello Developers!
I created some small vf-page to show related items from an object. On this page I enabled inline editing and my page looks like this:
And here is my controller extension to save the changes:
I created some small vf-page to show related items from an object. On this page I enabled inline editing and my page looks like this:
<apex:page StandardController="Milestone1_Project__c" showHeader="true" sidebar="false" extensions="saveMilestones" tabStyle="Milestone1_Milestone__c"> <apex:pageMessages id="ex"/> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <apex:commandbutton action="{!saveit}" value="Saveit"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Header" collapsible="false"> <apex:outputField value="{!Milestone1_Project__c.Name}"/> </apex:pageBlockSection> <apex:pageBlock title="Milestones"> <apex:pageBlockTable value="{!Milestone1_Project__c.Project_Milestones__r}" var="ml" width="100%"> <apex:column value="{!ml.Name}" /> <apex:column headerValue="Kickoff" > <apex:outputField value="{!ml.Kickoff__c}"> <apex:inlineEditSupport event="ondblClick"/> </apex:outputField> </apex:column> <apex:column headerValue="Deadline" > <apex:outputField value="{!ml.Deadline__c}"> <apex:inlineEditSupport event="ondblClick"/> </apex:outputField> </apex:column> <apex:column headerValue="Complete" > <apex:outputField value="{!ml.Complete__c}"> <apex:inlineEditSupport event="ondblClick"/> </apex:outputField> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:pageBlock> </apex:form> </apex:page>
And here is my controller extension to save the changes:
public class saveMilestones { public Milestone1_Project__c proj{get;set;} public saveMilestones(ApexPages.StandardController stdController) { proj = [SELECT Id, Name , Opportunity1__c, (SELECT Id, Name, Kickoff__c, Deadline__c, complete__c, Project__c FROM Project_Milestones__r order by Name ) FROM Milestone1_Project__c where Id =:ApexPages.currentPage().getParameters().get('id')]; } public PageReference saveit(){ update proj.Project_Milestones__r; return null; } }It seems to save the new values, but if I go back to my master-object "Projects", I have all the old values in it - so indeed nothing is saved. What am I missing?
Pleaase feel free to use this code whenever you might need it.