Wizard Component - Create Multiple Child Records

  • 1
  • Question
  • Updated 8 months ago
  • Answered
  • (Edited)
Working with the Wizard component ... stepping the user through a series of questions that will first create a parent record then 1 to many child records all related to the parent object. Once a child record is created I am prompting the user "Create another child record?". If yes then I go back to a previous step in the wizard and the user enter information for another child record. 

I have the creation of the parent record working.  I have creation of the first child record working and it is related to the record.  However, can't figure out how to create another child record. When I display the step in the wizard to create a new child record I am seeing the child that was just created. 

Any ideas?
Photo of ksumner

ksumner

  • 120 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
That's a great wizard use case.  But these things get really complicated....

This is what I think needs to happen:

On Create another child record run the following action sequence. 

1. Save parent
2. Save child 1
3. Empty rows on the child model
4. Create new row on child model.   I think the condition will pre-populate the data with the right parent ID.  You'll want to check this tho. 
5. Go back to the child definition step of the wizard. 

I think that should do what you are looking for. 
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
Sorry to resurface this one - but I'm trying to do something kind of similar. I want to use a wizard to:

Step 1: create a parent record (expense report) and then move on to
Step 2: a table that allows the user to create child records (expense line items). I don't have a ton of experience with action sequences - so I'm a little stumped on how to get started. Are there any tutorials or other posts with explanations or xml I could copy and use as a reference?
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Kaede,

I don't think you need to use the action sequence.  Just make sure to set a condition on your expense report lookup field on your expense line item record to the Id of the model of your expense report.  Skuid will take care of setting the right 'Id' when you save the expense line item model.

Here is an example page that shows this.  You can create a 'parent' account and 'child' contacts.  It uses a 2 step wizard.  As an alternative, you can also have a single page that shows the expense report fields at the top and a table to allow entry of child expense line items.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Account">
    <models>
        <model id="Account" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" sobject="Account">
            <fields>
                <field id="Name"/>
                <field id="Id"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model limit="20" query="false" createrowifnonefound="true" datasource="salesforce" id="Contact" sobject="Contact">
            <fields>
                <field id="RecordTypeId"/>
                <field id="FirstName"/>
                <field id="LastName"/>
            </fields>
            <conditions>
                <condition type="modelmerge" value="" field="AccountId" fieldtargetobjects="Account" operator="=" model="Account" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="noquery"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <wizard deferstepcontentsrendering="false" buttonslocation="top" uniqueid="sk-3xJWeA-238">
            <steps>
                <step stepid="step1" steplabel="Step 1">
                    <components>
                        <basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="edit" uniqueid="sk-3xJUwd-212">
                            <columns>
                                <column width="100%">
                                    <sections>
                                        <section title="Basics">
                                            <fields>
                                                <field id="Name" uniqueid="sk-3xJUwQ-207"/>
                                            </fields>
                                        </section>
                                    </sections>
                                </column>
                            </columns>
                        </basicfieldeditor>
                    </components>
                    <actions>
                        <action uniqueid="sk-3xJWe9-235" type="navigate" stepid="step2" label="Next Step" icon="sk-icon-arrow-right" window="self"/>
                    </actions>
                </step>
                <step stepid="step2" steplabel="Step 2">
                    <components>
                        <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Contact" buttonposition="" mode="edit" allowcolumnreordering="true" responsive="true" uniqueid="sk-3xJtPM-382">
                            <fields>
                                <field id="FirstName" hideable="true" uniqueid="fi-3xKHut-604"/>
                                <field id="LastName" hideable="true" uniqueid="fi-3xKHuu-605"/>
                            </fields>
                            <rowactions>
                                <action type="edit"/>
                                <action type="delete"/>
                            </rowactions>
                            <massactions usefirstitemasdefault="true">
                                <action type="massupdate"/>
                                <action type="massdelete"/>
                            </massactions>
                            <views>
                                <view type="standard"/>
                            </views>
                        </skootable>
                    </components>
                    <actions>
                        <action uniqueid="sk-3xJWeA-236" type="navigate" stepid="step1" label="Previous Step" icon="sk-icon-arrow-left" secondary="true"/>
                        <action uniqueid="sk-3xJWeA-237" type="multi" icon="sk-icon-save" window="self" label="Save">
                            <actions>
                                <action type="save">
                                    <models>
                                        <model>Account</model>
                                        <model>Contact</model>
                                    </models>
                                </action>
                                <action type="redirect" window="self" url="/{{{$Model.Account.data.0.Id}}}"/>
                            </actions>
                        </action>
                    </actions>
                </step>
            </steps>
        </wizard>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
        <actionsequences uniqueid="sk-3xJhhv-324"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
This is perfect - so helpful. Thank you!!!