Global action "Create new row in model" doesn't set context properties on new record

When inside a component that has context (in my case a drawer), when a global action of “Create new row in Model” is invoked, the row gets created in the model but the parent properties are not established on the new record.

Note - The expected behavior works if you use the stock “in-line” add new record and also works if you use the Action Type on the global action for “Create new row.” The problem only seems to be when run multiple actions is specified and “Create new row in model” is chosen.

Steps to reproduce:

  1. Create new account tab page
  2. Add model for contact
  3. Add table for accounts
  4. Add row action drawer for contacts and setup the table to have context on AccountId and add a couple of fields to table output
  5. Ensure “Allow inline record creation” is checked
  6. Add a global action for “Create new row” labeling it “Add New Direct”
  7. Add a global action for “Run multiple actions”, label it “Add New Multiple” and specify an action of “Create new row in model”
  8. Preview the page
  9. Click #5 button - works as expected
  10. Click #6 global action - works as expected
  11. Check skuid.$M(‘Contact’).data.length
  12. Click #7 global action - No row is visible
  13. Check skuid.$M(‘Contact’).data.length

Actual result:
Row is added in Step #12 but not visible because AccountId on the new row was not set

Expected Result:
Row is visible and AccountId set to the id of the row in context

Sample Page

<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Account">   <models>
      <model id="Account" limit="100" query="true" createrowifnonefound="false" sobject="Account">
         <fields>
            <field id="Name"/>
            <field id="CreatedDate"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
      <model id="Contact" limit="20" query="true" createrowifnonefound="false" sobject="Contact" doclone="" type="">
         <fields>
            <field id="Name"/>
            <field id="FirstName"/>
            <field id="LastName"/>
            <field id="AccountId"/>
            <field id="Account.Name"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="Account" mode="read" buttonposition="">
         <fields>
            <field id="Name" allowordering="true"/>
            <field id="CreatedDate" allowordering="true"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
            <action type="multi" label="Show Contacts" icon="sk-icon-magic">
               <drawer title="Drawer Area" width="800" closehandle="true">
                  <components/>
               </drawer>
               <actions>
                  <action type="drawer">
                     <drawer title="Drawer Area" width="800" closehandle="true">
                        <components>
                           <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Contact" buttonposition="" mode="read">
                              <fields>
                                 <field id="FirstName"/>
                                 <field id="LastName"/>
                                 <field id="Name"/>
                              </fields>
                              <rowactions/>
                              <massactions usefirstitemasdefault="true"/>
                              <views>
                                 <view type="standard"/>
                              </views>
                              <conditions>
                                 <condition type="contextrow" field="AccountId" mergefield="Id"/>
                              </conditions>
                              <actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true">
                                 <action type="multi" label="Add New Multiple" icon="sk-icon-add">
                                    <drawer title="Drawer Area" width="800" closehandle="true">
                                       <components/>
                                    </drawer>
                                    <actions>
                                       <action type="createRow" model="Contact" appendorprepend="prepend" defaultmodefornewitems="edit"/>
                                    </actions>
                                 </action>
                                 <action type="createrow" appendorprepend="prepend" label="Add New Direct">
                                    <drawer title="Drawer Area" width="800" closehandle="true">
                                       <components/>
                                    </drawer>
                                 </action>
                              </actions>
                           </skootable>
                        </components>
                     </drawer>
                  </action>
               </actions>
               <renderconditions logictype="and"/>
            </action>
         </rowactions>
         <massactions usefirstitemasdefault="true"/>
         <views>
            <view type="standard"/>
         </views>
         <searchfields/>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
</skuidpage>

Thanks for sending this bug report.  We will check it out.  

Arguments could probably be made either way that the Create new Row action in the Action Framework, when called from a Table action, should or should not automatically populate this information — but I think that I would agree with you here Barry.

In the meantime, the easy workaround is to add a Default Value on the Create new row action which populates the AccountId field using the Id of the context row:

This has been fixed / implemented in the Superbank release.

When is the next release?

All customers should be getting an email within the next week answering this question :slight_smile:

You make a compelling point above Zach, I hadn’t considered it more globally (no pun intended).  I think you’re right, could see it both ways especially in the case of secondary models that you might create rows in as part of a global action.  The question would be - when should context properties (if available) be applied and when not.  I’m assuming the solution you’ve put together does something along the lines of checking context and if the model type is the same as the type on the model row being created, context properties are applied?  

Possibly a toggle option on create new row in model to “apply/don’t apply context properties”?  At the core, I agree with where you ended up, “create new row” action type and “create new row in model” framework action (at least for a global action on a table) should behave similarly assuming the same model is used.  Of course, there will be situations where things like creating a new contact on the parent account would be desired so having the toggle option would provide flexibility.

Food for thought.  Thanks for the quick response!

Yes, the way we implemented was this: Is there a context List involved when creating the new row? Is its Model the same as the Model we’re creating new rows in? Does the context List have Context Conditions? Only if all of these are true, do we grab and apply those Context Conditions, and these Conditions are applied prior to any extra “Default Values” that are specified for the Create new Row Action, so it’s always possible to override if necessary. This basically makes the functionality equivalent to the Table standard buttons for Create new Row.

Makes sense and provides the default values provides the same end result as having a toggle option to “apply/don’t context values”.  This change also makes it behave like global actions on tables that don’t have context when create new row in model is used.  For example, in the current release, an account detail page with a contacts table would result in accountid being set when global action create new row in model is invoked.  It’s only when going a layer underneath via context it wasn’t.  So functional parity now :slight_smile:

Thanks again!