create row mass action does not use selected rows as context

  • 2
  • Problem
  • Updated 2 months ago
  • Acknowledged
9.5.10

Here's the summary of the problem:
A mass action on a table (perhaps only in a wizard) in a popup uses the context of the pagetitle component that launched the popup rather than the rows selected on the table for a create row(s) action.

A complete description:
I have a page which is designed to assign a custom version of 'tasks' to users via a junction model.

I have a page title on Model A with a button. The button queries Model B and opens a popup.
The popup contains a wizard which contains 3 steps. The first step is just selecting some users (trainee and trainer) from lookups on a dummy model to be used in a create row operation. The second step shows a table on Model B, which is a list of all available tasks. This table has a mass action setup to create rows on the junction object (Model C, called "Training_CreateIndividualTraining), like this:



The third step shows a table on Model C so you can check the tasks that have been created, if any.

Except, the mass action doesn't work.

Here's the table on Model B:


Notice that I've selected all rows, and that the ID field is in the 3rd column.

Here's the result of the mass action:

One row was created, and it has the wrong Id.

The context that the create row mass action is using is apparently not the selected rows of the table. Instead, it's using the row of the page title component that launched the popup.

Problem!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 1 year ago

  • 2
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Can you recreate a simple reproduction page using standard objects? I can try and use your steps to recreate one, but there are quite a few for this one and it'll take some time to get back to you.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Here you go:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">
    <models>
        <model id="Accounts" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
            <fields>
                <field id="Id"/>
                <field id="Name"/>
                <field id="OwnerId"/>
                <field id="Owner.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="Contacts" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="Id"/>
                <field id="Name"/>
                <field id="OwnerId"/>
                <field id="Owner.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="CreateCases" limit="" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Case">
            <fields>
                <field id="ContactId"/>
                <field id="Contact.Name"/>
                <field id="OwnerId"/>
                <field id="Owner.Name"/>
                <field id="Id"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="UserSelect_Case" limit="0" query="false" createrowifnonefound="true" datasource="salesforce" type="" sobject="Case" doclone="" unloadwarningifunsavedchanges="false">
            <fields>
                <field id="OwnerId"/>
                <field id="Owner.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Accounts" uniqueid="sk-fdidE-140">
            <maintitle>
                <template>{{Name}}</template>
            </maintitle>
            <subtitle>Page Title Component on the Accounts Model</subtitle>
            <actions>
                <action type="multi" label="New Button">
                    <actions>
                        <action type="blockUI" message="Query Contacts and Show Popup"/>
                        <action type="requeryModel" model="Contacts" behavior="standard"/>
                        <action type="showPopup">
                            <popup title="New Popup" width="90%">
                                <components>
                                    <wizard deferstepcontentsrendering="false" buttonslocation="top" uniqueid="sk-ffqU0-317">
                                        <steps>
                                            <step stepid="step1" steplabel="Step 1">
                                                <components>
                                                    <richtext multiple="false" uniqueid="sk-fha2f-626">
                                                        <contents>&lt;p&gt;&lt;span style="color:#ff8c00;"&gt;Select a User.&lt;/span&gt;&lt;/p&gt;
</contents>
                                                    </richtext>
                                                    <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="UserSelect_Case" buttonposition="" uniqueid="sk-fft42-334" mode="edit">
                                                        <columns>
                                                            <column width="100%">
                                                                <sections>
                                                                    <section title="Section A" collapsible="no">
                                                                        <fields>
                                                                            <field id="OwnerId" valuehalign="" type="REFPICK"/>
                                                                        </fields>
                                                                    </section>
                                                                </sections>
                                                            </column>
                                                        </columns>
                                                    </basicfieldeditor>
                                                </components>
                                                <actions>
                                                    <action uniqueid="sk-ffqT--314" type="navigate" stepid="step2" label="Next Step" icon="sk-icon-arrow-right"/>
                                                </actions>
                                            </step>
                                            <step stepid="step2" steplabel="Step 2">
                                                <components>
                                                    <richtext multiple="false" uniqueid="sk-fhTTs-547">
                                                        <contents>&lt;p&gt;&lt;span style="color:#ff8c00;"&gt;Select a few rows and click &amp;quot;Create Rows&amp;quot; mass action. Then click Next Step to see what you&amp;#39;ve created.&lt;/span&gt;&lt;/p&gt;
</contents>
                                                    </richtext>
                                                    <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Contacts" buttonposition="" mode="readonly" allowcolumnreordering="true" uniqueid="sk-fg3RB-360">
                                                        <fields>
                                                            <field id="Name" hideable="true" uniqueid="fi-fgBTC-383"/>
                                                            <field id="AccountId" hideable="true" uniqueid="fi-fgBTC-384"/>
                                                        </fields>
                                                        <rowactions/>
                                                        <massactions usefirstitemasdefault="true">
                                                            <action type="multi" label="Create Rows" icon="sk-icon-magic">
                                                                <actions>
                                                                    <action type="createRow" model="CreateCases" appendorprepend="append" defaultmodefornewitems="edit" affectedrows="context">
                                                                        <defaults>
                                                                            <default type="fieldvalue" field="ContactId" fieldtargetobjects="Contact" enclosevalueinquotes="true" value="{{Id}}"/>
                                                                            <default type="fieldvalue" field="Contact.Name" enclosevalueinquotes="true" value="{{Name}}"/>
                                                                            <default type="fieldvalue" field="OwnerId" fieldtargetobjects="Group,User" enclosevalueinquotes="true" value="{{$Model.UserSelect_Case.data.0.OwnerId}}"/>
                                                                        </defaults>
                                                                    </action>
                                                                </actions>
                                                            </action>
                                                        </massactions>
                                                        <views>
                                                            <view type="standard"/>
                                                        </views>
                                                    </skootable>
                                                </components>
                                                <actions>
                                                    <action uniqueid="sk-ffqT--315" type="navigate" stepid="step1" label="Previous Step" icon="sk-icon-arrow-left"/>
                                                    <action uniqueid="sk-ffqT--316" type="navigate" label="Next Step" icon="sk-icon-arrow-right" window="self" stepid="step3"/>
                                                </actions>
                                            </step>
                                            <step stepid="step3" steplabel="Step 3">
                                                <components>
                                                    <richtext multiple="false" uniqueid="sk-fhdrt-646">
                                                        <contents>&lt;p&gt;&lt;span style="color:#ff8c00;"&gt;As you can see, the create rows action used the context of the pagetitle that launched the popup instead of the selected rows in the action&amp;#39;s table.&lt;/span&gt;&lt;/p&gt;
</contents>
                                                    </richtext>
                                                    <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="CreateCases" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-fgEx9-391">
                                                        <fields>
                                                            <field id="Id" hideable="true" uniqueid="fi-fh2qQ-486" valuehalign="" type=""/>
                                                            <field id="ContactId" hideable="true" uniqueid="fi-fh2qQ-487" valuehalign="" type=""/>
                                                            <field id="OwnerId" hideable="true" uniqueid="fi-fh2qR-488" valuehalign="" type=""/>
                                                        </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-ffr0K-326" type="navigate" stepid="step2" label="Previous Step" icon="sk-icon-arrow-left"/>
                                                    <action uniqueid="sk-ffr0K-327" type="navigate" label="Next Step" icon="sk-icon-arrow-right"/>
                                                </actions>
                                            </step>
                                        </steps>
                                    </wizard>
                                </components>
                            </popup>
                        </action>
                        <action type="unblockUI"/>
                    </actions>
                </action>
            </actions>
        </pagetitle>
        <richtext multiple="false" uniqueid="sk-fi0cD-814">
            <contents>&lt;p&gt;&lt;span style="color:#ff8c00;"&gt;Click the New Button to begin.&lt;/span&gt;&lt;/p&gt;
</contents>
        </richtext>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
    <interactions/>
</skuidpage>
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Thank you for bringing this to our attention. I have been able to reproduce this error and have it logged within our system. I'll update here when the fix is released. We do not have a workaround currently. We have noticed that this behavior only affects pop ups in Button Sets and Page Titles.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
You don't have a workaround?

Seems like the obvious thing in this case is to use a brute-force javascript method. Shouldn't be too difficult to build a snippet that will get the selected rows in the table, build a rowsToCreate object, and run createRows().

Right?
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
I have requested for a quick workaround from the devs but unfortunately this is two issues. 1. The context is screwy. 2. Mass Actions are only creating one record. 
I have not tried approaching this from a "Page Include within the Pop Up" method. That might work but would take some building.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I think it's really one issue. The create row(s) action only sees one record in context, and therefore is only creating one row.

If you fix the context, the row creation will work as expected.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
The page include is probably the way to go, particularly in our case since we don't care what the context of the component that is launching the popup is. We wouldn't even need to pass any parameters to the page include in this case.
Photo of Steve Wasula

Steve Wasula

  • 220 Points 100 badge 2x thumb
I've got a popup from within a Drawer that appears to be having the same problem.  
Photo of Jeremy Aranda

Jeremy Aranda

  • 124 Points 100 badge 2x thumb
I have a popup also having the same issue.
Photo of Arne-Per Heurberg

Arne-Per Heurberg

  • 1,336 Points 1k badge 2x thumb
bump
Photo of Gary Bailey

Gary Bailey

  • 1,628 Points 1k badge 2x thumb
so....any updates on this?  I'm running into same issue.  I'm trying to reproduce the functions of a "clone" button on a record in a deck.  I've selected "create new row" as the first action and under "rows to use" I've selected "rows in context" but it is still pulling the data from the 1st row in the model.  

Am I misunderstanding what the "rows in context" means?