Skip to main content

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!

bump


RackMultipart20170825-67722-12fxj3-TVMr._Bump_inline


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.


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>&amp;lt;p&amp;gt;&amp;lt;span style="color:#ff8c00;"&amp;gt;Select a User.&amp;lt;/span&amp;gt;&amp;lt;/p&amp;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>&amp;lt;p&amp;gt;&amp;lt;span style="color:#ff8c00;"&amp;gt;Select a few rows and click &amp;amp;quot;Create Rows&amp;amp;quot; mass action. Then click Next Step to see what you&amp;amp;#39;ve created.&amp;lt;/span&amp;gt;&amp;lt;/p&amp;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>&amp;lt;p&amp;gt;&amp;lt;span style="color:#ff8c00;"&amp;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;amp;#39;s table.&amp;lt;/span&amp;gt;&amp;lt;/p&amp;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>&amp;lt;p&amp;gt;&amp;lt;span style="color:#ff8c00;"&amp;gt;Click the New Button to begin.&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
</richtext>
</components>
<resources>
<labels/>
<javascript/>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
<interactions/>
</skuidpage>

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.


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?


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.


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.


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.


I’ve got a popup from within a Drawer that appears to be having the same problem.  


I have a popup also having the same issue.


bump


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?   


I am experiencing this issue - is there any update on when this may be resolved? 


I’m having the same issue.  v12.2.10


I seem to be having this issue with relation to using the “Adopt Rows into Model” as a “Mass Action” - it is not considering the rows in context, just all rows.


Hi @smdrich



  • What version of Skuid are you using?




Are you building in api v1 or v2?

Here is a workaround to this problem. (though were gonna fix the problem)


If you can move the “create row” action to happen as a separate sequence that is fired on each row - the data context will be correct.


So the mass action could simply update a field value on the row. And a model action on that row update could trigger the row creation. The model action would repeat every time and should get the right data context for the pre-population steps.


I hope this helps anyone who finds this post sometime in the future.


As a side note to this, in the API there appears to be no createRows function. You can only create 1 row at a time via model.createRow:


https://docs.skuid.com/latest/en/skuid/api/skuid_model_model.html


this also has the unfortunate side-effect of, if trying to mass create rows, pushing an “update the UI display” call with each row created. If a table was ever displayed on the page, this can cause a massive slowdown when creating the rows in a loop, and can even cause your page to freeze.


As a workaround to this, I generally run my mass row creation in a duplicate model that has the same properties as my original model, just named “_NODISPLAY” because I never display it on the page, therefore the individual row creates don’t push a UI display update. When done creating rows in that model I then adopt all rows from that model into my normal displayed model.


It would be great if this wasn’t so complicated and we simply had a “createRows” function that accepted an array of field value pairs, similar to how updateRow also has an updateRows function.


Reply