You need to sign in to do that
Don't have an account?
benton
Save child join fields in datatable
I have a VF page that shows a datatable with a master-child relationship join. I have an input field on the child objects but can not figure out how to save. Everything displays properly but will not save my changes to child objects.
VF Page:
<apex:pageBlockButtons > <apex:commandButton action="{!save4}" id="saveButton" value="Save"/> <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/> </apex:pageBlockButtons> <apex:pageblockTable value="{!acclist}" var="o"> <apex:column width="10%" style="text-align:center;" headerValue="Name"><apex:outputField value="{!o.name}"/> </apex:column> <apex:column headerValue="Line_Items"> <apex:pageBlockTable value="{!o.Line_Items__r}" var="a"> <apex:column width="4%" style="text-align:center;" headerValue="Pay Vendor"><apex:inputField value="{!a.Vendor_Paid__c}"/> </apex:column> <apex:column width="4%" style="text-align:center;" headerValue="InvRcd"><apex:outputField value="{!a.Invoiced_Received__c}"/> </apex:column> </apex:pageBlockTable> </apex:column> </apex:column> </apex:pageblockTable>
Controller:
acclist = [Select name, id, (SELECT Name,Invoiced_Received__c, Vendor_Paid__c, Service_Order__c from Line_Items__r) From Account where id IN (Select Vendor__c from Line_Item__c) ORDER BY name];\
public PageReference save4() {
update acclist;
return null;
}
All Answers
You will need to explicitly update the rows you've retrieved with the inner query.
A save on the parent will not commit the changes on the child.
Nevermind to that. It was just a typo. But when I save on my VF Page I get a VisualFOrce Error
System.QueryException: List has more than 1 row for assignment to SObject
Perfect. your awesome. I appreciate the help.