Mass Action Create New Rows- I can't get this to work

  • 2
  • Question
  • Updated 1 year ago
  • Answered
I am trying to use a Mass Action on an Account list to create new records on a custom object called Sales Initiatives (related object to Account).  I am using rows in context because I want a new Sales Initiative record created for each account selected.  

When I select my rows and hit this mass action button, nothing happens.  No row is created.

Photo of Steve Chilcoat

Steve Chilcoat

  • 522 Points 500 badge 2x thumb

Posted 1 year ago

  • 2
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
I created an XML page that reproduces what I think you're wanting. It can be a good starting point for troubleshooting this. In it, I have a mass action that adds a specific description to contacts and keeps context from the accounts chosen in the first table. Does it show what you're wanting to do and how you're trying to do it?

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">    <models>
        <model id="account" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
            <fields>
                <field id="Name"/>
                <field id="Id"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="contact" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="FirstName"/>
                <field id="LastName"/>
                <field id="Description"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="account" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1OoG5O-106">
            <fields>
                <field id="Name" hideable="true" uniqueid="fi-1OoQ5n-120"/>
                <field id="Id" hideable="true" uniqueid="fi-1OpyDb-342" valuehalign="" type=""/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="multi" label="Add Contacts" icon="sk-icon-magic">
                    <actions>
                        <action type="createRow" model="contact" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
                            <defaults>
                                <default type="fieldvalue" field="Description" fieldtargetobjects="Contact" enclosevalueinquotes="true" value="Whatever I want EXAMPLE"/>
                                <default type="fieldvalue" field="AccountId" fieldtargetobjects="Account" enclosevalueinquotes="true" value="{{Id}}"/>
                            </defaults>
                        </action>
                    </actions>
                </action>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="contact" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1OpB91-231">
            <fields>
                <field id="FirstName" hideable="true" uniqueid="fi-1OpE8d-246"/>
                <field id="LastName" hideable="true" uniqueid="fi-1OpE8e-247"/>
                <field id="Description" hideable="true" uniqueid="fi-1OpE8e-248"/>
                <field id="AccountId" hideable="true" uniqueid="fi-1OpdaA-282" valuehalign="" type=""/>
                <field id="Account.Name" hideable="true" uniqueid="fi-1OpdaA-283"/>
            </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>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
(Edited)
Photo of Steve Chilcoat

Steve Chilcoat

  • 522 Points 500 badge 2x thumb
Thanks.  Yes. This works.  Adding the table I am writing to to my page helps.  I believe my records weren't saving because I have validation rules on a few fields.  By having the records appear in a table I can see where the data needs to be added.  

Now I need to figure out how to populate the data in these fields. Unfortunately they are picklist fields that the user needs to choose ahead of time and apply to all.  I can't set a "default" in the action.  Any suggestions?  Can I open a popup window first, have the user input the data there, then execute the create new records?  
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
You should be able to select a picklist automatically as well in the same method. It just has to be an existing picklist option. You can't set it to a picklist that doesn't exist. 
Photo of Steve Chilcoat

Steve Chilcoat

  • 522 Points 500 badge 2x thumb
I need the user to choose which value in the picklist they want though.  I don't want to set it for them.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
If I understand your question correctly, you can probably do a Ui only model and add the picklist fields. Add a field editor to collect the user input. Then in your action sequence update fields on rows with the values from the UI only model.
Photo of Steve Chilcoat

Steve Chilcoat

  • 522 Points 500 badge 2x thumb
Trying this.  The Action sequence doesn't seem to allow using fields from another model to set values.  You can only choose from "Single Specified Value" or "None-Blank Value".