function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Allan NolandAllan Noland 

Do you have to use a custom controller or an extension controller of the standard controller to save information on a child object when you use the parent's standard controller

Hello,

I am using the opportunity standard controller to create an input screen for some information.  Part of the captured information resides on a child object of the opportunity.  using the quicksave action of the standard controller saves information relative to the opportunity how do i get it to save information on the child record too.  Here is the code i am using
 
<apex:page Standardcontroller="Opportunity" recordSetVar="Opp" standardStylesheets="True" showHeader="false"    >
    <apex:Form >
        <apex:pageBlock title="Revenue List" mode="Edit">
        <apex:pageBlockButtons location="both">
            <apex:commandButton action="{!previous}" value="Previous"/>
            <apex:commandButton action="{!quickSave}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
            <apex:commandButton action="{!next}" value="Next"/>
        </apex:pageBlockButtons> 
        <apex:selectList value="{!filterid}" size="1">
          <apex:selectOptions value="{!listviewoptions}"/>
      </apex:selectList>
      <apex:commandButton action="{!first}" value="Apply"/>    
            <apex:pageBlockTable value="{!Opp}" var="op" width="100%">
              <apex:Column width="100 (px)" value="{!op.Ownerid}" headerValue="Owner"></apex:Column>
              <apex:Column value="{!op.id}"></apex:Column>
              <apex:Column width="200 (px)" value="{!op.Name}" headerValue="Opportunity"></apex:Column>
              <apex:Column headerValue="Stage"><apex:inputfield value="{!op.StageName}" /></apex:Column>
            <apex:column >
            <apex:pageBlockTable value="{!Op.RevenueProjections__r}" var="re">
              <apex:Column width="50(px)"  headerValue="Year"><apex:inputfield value="{!re.Year__c}" /></apex:Column>
              <apex:Column width="50(px)"  headerValue="January"><apex:inputfield value="{!re.January__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="February"><apex:inputfield value="{!re.February__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="March"><apex:inputfield value="{!re.March__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="April"><apex:inputfield value="{!re.April__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="May"><apex:inputfield value="{!re.May__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="June"><apex:inputfield value="{!re.June__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="July"><apex:inputfield value="{!re.July__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="August"><apex:inputfield value="{!re.August__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="Setember"><apex:inputfield value="{!re.September__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="October"><apex:inputfield value="{!re.October__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="November"><apex:inputfield value="{!re.November__c}"/></apex:Column>
              <apex:Column width="50(px)"  headerValue="December"><apex:inputfield value="{!re.December__c}"/></apex:Column>
          </apex:pageBlockTable>           
          </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:Form>
</apex:page>

 
Ajay K DubediAjay K Dubedi
Hello Allan,
If have used action quickSave and upto my information there is no standard action for quick save for this you have to write a cotroller and use that as extension on the page.
eg:
public class test {
Public opportunity opp {get; set;}
ApexPages.StandardController op;

public test(ApexPages.StandardController controller){
op=controller;
    opp=(Opportunit)controller.getRecord();
}
public PageReference quickSave(){
    if(opp!-null){

    insert opp;
    return op.edit();
}
}
}