last day (29 days later) » 

9:42 PM
Hi Rao
 
Rao
hey Tyler,
How are you and whats that you are trying to do
 
So it looks like I'm trying to create multiple records, each of which use a different object type, on a single visualforce page
 
Rao
If I get your question right you need to create a VF page where you can create a bunch of input fields and get input on both Parent and child object and save both at the same time correct?
 
Yup
 
Rao
so you have 2 object in master detail 1) Custom object A - master 2) Custom object B- child correct?
 
9:48 PM
Check it out
there is a 3rd object
All 3 need to be created on a single page
 
Rao
gotcha
1) You need to understand what is a controller/ Standard controller/ Extension
 
I do sorta
I think an extension will work for my problem, correct?
 
Rao
it will but
do you need a standard controller is the question
 
all I need to do is create new records
User fills out the form, and hits save
 
Rao
Ok lets focus on that first
<apex:page sidebar="false" standardStylesheets="false" standardController="Custom_Object_A__c">
    <apex:form>

    <apex:pageBlock title="Create Two New Records">

        <apex:pageBlockSection>
            <apex:inputField value="{! Custom_Object_A__c.Name}"/>
        </apex:pageBlockSection>

        <apex:pageBlockSection>
            <apex:inputField value="{! Custom_Object_A__c.Custom_Object_B__r.Name}"/>
        </apex:pageBlockSection>

        <apex:pageBlockButtons>
            <apex:commandButton action="{! save }" value="Save" />
This is your problem : Custom_Object_A__c.Custom_Object_B__r.Name
your data model is Custom object A ( Parent) and Custom object B(child)
you can use . (dot) notation only when you are accessing parent fields from child
 
9:53 PM
Yeah I got that thanks
 
Rao
for the other way you need a SOQL query to get the relationship
since you are building this on a standard controller you need to have extension defined to query the child fields from the parent
Step1 :
in the above code define an extension
<apex:page sidebar="false" standardStylesheets="false" standardController="Custom_Object_A__c" extensions="sensible_named_controller">
sensible_named_controller: define a controller / apex class name and save your vf page
let me know when you do this and we can write the extension for this page
 
Okay so use the standard controller for the parent object?
 
Rao
Salesforce for the sake of convenience provides prebuilt methods like save/ insert/ delete etcc...
when you do not wnat to have your custom logic written out you can use a standard controller and save the record
when you have a custom save logic then you go and start controller / extension
To answer ur question : Yes use parent object as the standard controller
let me know if the page saved and prompted you to create a class
 
K i made the extension and included it in my class
 
Rao
10:08 PM
awesome can you post your extension
 
public class NewSurveyExtension {

}
 
Rao
just a min
how do you want your design to be
Step 1: save parent record
Step 2: save the child 1
Step 3: save the child 2
(or)
Get all the parent child1 child2 on the same page, take all the info process it in the controller
 
I'm not sure, the first one seems right
Also, I'm not sure if this affects the decision, I want to be able to dynamically create multiple childs on the page if the user hits a button
and preview the records on one page before saving them
 
Rao
hmm so there is one button and the user hits save, and the parent/ child1 / child 2 record needs to be saved correct
<apex:page sidebar="false" standardStylesheets="false" standardController="Custom_Object_A__c" extensions="NewSurveyExtension">
	<apex:form>

	<!-- Custom object A fields-->
	<apex:pageBlock title="Create Two New Records">

	<apex:pageBlockSection>
	<apex:inputField value="{! Custom_Object_A__c.Name}"/>
	</apex:pageBlockSection>

	<apex:pageBlockButtons>
	<apex:commandButton action="{! save }" value="Save" />
	</apex:pageBlockButtons>

	</apex:pageBlock>

	<!-- Custom object B fields. -->
	<apex:pageBlock title="Create Two New Records">
opps sorry
The page should look like this then
<apex:page sidebar="false" standardStylesheets="false" standardController="Custom_Object_A__c" extensions="NewSurveyExtension">
<apex:form>

<!-- Custom object A fields-->
<apex:pageBlock>

<apex:pageBlockSection>
<apex:inputField value="{! Custom_Object_A__c.Name}"/>
</apex:pageBlockSection>

</apex:pageBlock>

<!-- Custom object B fields. -->
<apex:pageBlock>

<apex:pageBlockSection>
<apex:inputField value="{! Custom_Object_A__c.Name}"/>
</apex:pageBlockSection>

</apex:pageBlock>

<!-- Custom object C fields.-->
 
shouldn't the apex:inputField for B & C be this
<apex:inputField value="{! Custom_Object_B__c.Name}"/>
<apex:inputField value="{! Custom_Object_C__c.Name}"/>
 
Rao
10:23 PM
yes copy pasted the same set sorry about that
 
okay what next
 
Rao
gimme a minute gettting pinged at work :(
 
thank you for your time1
!
public class NewSurveyExtension {

    List<SEO__CSEO_Survey_Question__c> questions = new List<SEO__CSEO_Survey_Question__c>();
    List<SEO__CSEO_Referral_Site__c> referrals = new List<SEO__CSEO_Referral_Site__c>();

    public NewSurveyExtension(ApexPages.StandardSetController std) {
    	questions = (SEO__CSEO_Survey_Question__c)std.getRecords();
        referrals = (SEO__CSEO_Referral_Site__c)std.getRecords();
    }
}
 
Rao
10:46 PM
Tyler have to run for a meting, I will come back here soon in case i don't I will connect with you on twitter and lets get this off your way :)
 
Okay thank you
 

last day (29 days later) »