How do I delete all rows in a model using action framework?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
I have a wizard that is automatically creating multiple children records in a pop up when a button is clicked.  In order to reorder the records correctly I have to save them in this process.  If the end user decides not to complete the wizard the records are already created.  I have a cancel button that can delete row(s) in the action framework but it does not delete all the rows.  Is there someway to delete all the records in a model with one click?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Use the "Remove all rows from Model" Action:



This will remove all the rows from the Model, and does not change any data in the database, so it's perfect for a wizard where you're creating new records.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Thanks Zach. I tried this, I am likely doing it wrong.  Does this just clear the model of the rows but doesn't delete them?  I need it to delete all the records in the model.
(Edited)
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Hi guys, how do you delete all rows from a model?
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
My Wizard creates and saves multiple records.  So if someone decides to abort the wizard or start over they need to click the cancel button and it literally delete all the records in that model.

Intuitively you may ask why are you saving the model.  You should just give the option to save or cancel:
The child records are created based on information from parent records.  One child record is created for every parent record.  The reason I save them is because after saving them I query the model to sort them in numeric order so it matches the paper form they are entering data from.  From what I can tell I can only sort the records if they are saved first.  If I could sort the records before saving that would be preferred.
(Edited)
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Okay, for those with this same question in the future here is what I did. . . With click no code.

  1.  Added a Delete records button that opened a pop up
  2. The pop up says "Are you sure you want to delete all the records?"
  3. Underneath the question I have a table that shows all the rows in that model. 
  4. Using the GLOBAL ACTIONS button on the table I have a "Run Multiple Actions" button.
  5. Since it is a Global Actions item the "Mark Row(s) for deletion" marks ALL the rows for deletion
  6. I then save the model 
  7. close the pop up.  
The global Action button shows up above the table and right underneath the question so it is in the perfect spot for them to click the button that says "Yes, delete all records and start over"

No code and it acts like a "Are you Sure you want to delete all records pop up."
(Edited)