AbandonRow not updating the model in page 2 of wizard

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have created a wizard with 3 pages. Page 1 uses a model of set up object. Page 2 uses the model of transaction object.

I implemented a custom delete action button which runs a javascript and uses abandonrow method. The sequence of steps for the problem are, as follows

a)  I delete a row in page 1 using this button,
b) I click a custom mass action button  on page 1 and the records from set up model are still available in page 2 throughh params.

I need to use the params from step 2 to create transaction records, which is creating unwanted records.

As a solution, I tried to add additional action('Save Model') after the javascript script runs but it is creating records in set up object.

Please help.
Photo of Kalyan Kuchi

Kalyan Kuchi

  • 176 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Kalyan, which version of Skuid are you running?

In Banzai (7.x), there are we have changed Model.prototype.abandonRow() so that the UI will update when you call this method - also there are "bulk" versions now which we recommend using instead if you are trying to abandon multiple rows, e.g. from a Mass Action:

- abandonRows(rowsArray) --- abandon a specific subset of the rows in a Model
- abandonAllRows() or emptyData() --- abandon all rows in the Model

All of these methods update the UI immediately when called, as of Banzai.

EVEN BETTER than this, though, is the fact that as of Banzai the Action Framework now includes Actions that do this "abandon row" behavior:

- Remove all rows in Model (same as abandonAllRows() or emptyData()
- Remove context rows in Model (calls abandonRow() if there's only one context row, e.g. from a Table Row Action, or abandonRows() on selected rows if called from a Table Mass Action)





Here is the XML for a sample page to use to play around with these capabilities once you've got Banzai installed:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Case">   
   <models>
      <model id="Case" limit="1" query="false" createrowifnonefound="true" sobject="Case">
         <fields>
            <field id="Subject"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Case" uniqueid="sk-4NQcX-65">
         <maintitle>New {{Model.labelPlural}}</maintitle>
         <subtitle>
            <template>{{Model.labelPlural}}</template>
         </subtitle>
         <actions>
            <action type="multi" label="New" icon="sk-icon-add">
               <actions>
                  <action type="createRow" model="Case" appendorprepend="prepend" defaultmodefornewitems="edit">
                     <defaults>
                        <default type="fieldvalue" field="Subject" enclosevalueinquotes="true" value="blah"/>
                     </defaults>
                  </action>
               </actions>
            </action>
            <action type="multi" label="remove all" icon="sk-icon-delete">
               <actions>
                  <action type="emptyModelData">
                     <models>
                        <model>Case</model>
                     </models>
                  </action>
               </actions>
            </action>
         </actions>
      </pagetitle>
      <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="Case" buttonposition="" mode="edit" uniqueid="sk-4NRhR-77" emptysearchbehavior="query">
         <fields>
            <field id="Subject"/>
         </fields>
         <rowactions>
            <action type="multi" label="Remove" icon="sk-icon-delete">
               <actions>
                  <action type="abandonRows" model="Case"/>
               </actions>
            </action>
         </rowactions>
         <massactions usefirstitemasdefault="true">
            <action type="multi" label="Remove selected rows" icon="sk-icon-delete">
               <actions>
                  <action type="abandonRows" model="Case"/>
               </actions>
            </action>
         </massactions>
         <views>
            <view type="standard"/>
         </views>
         <searchfields/>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Kalyan Kuchi

Kalyan Kuchi

  • 176 Points 100 badge 2x thumb
Zach,

Thanks for the super fast response!!

Our version is 6.8.17. Using Banzai is not possible at this point.

 I am not sure how else I am going to solve this issue :-(.

Kalyan.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hi Kalyan,

If you want to force an update of the UI in pre-Banzai, you can call model.notifyEditorsOfDataRefresh() immediately after finishing your abandonRow() call(s).
Photo of Kalyan Kuchi

Kalyan Kuchi

  • 176 Points 100 badge 2x thumb
Mr. Zach,

You  look like a life saver.

It works.

 Thank you!!