Skip to main content
Nintex Community Menu Bar
Question

abandonRows() not working in JS

  • July 10, 2024
  • 5 replies
  • 30 views

Forum|alt.badge.img+8

This is weird. I have a abandonRows()  followed by model.save() in javascript. It seems to work from the UI. That is the table list is refreshed and from the console, it shows the data is removed. But it is actually not delete from the database. Is that correct?

This topic has been closed for replies.

5 replies

Forum|alt.badge.img+10
  • Nintex Employee
  • July 10, 2024

Hi Jili. Looking at our API documentation, abandonRows() will remove an array of rows from a model without requesting that that the rows be deleted from the database. It sounds like you’re looking for the model.save() to save changes and delete the abandoned rows from the model. If that’s what you’re aiming for, I believe you would explicitly need to mark them for deletion, and then save the model changes. deleteRow() may be what you’re after - I would suggest experimenting with this in a safe non-critical environment and checking the API documentation for usage details. Also, undeleteRow() may be good to know about, if you want to undo the action of marking the row for deletion.


Forum|alt.badge.img+8
  • Author
  • July 10, 2024

Thanks! Yes I read the documentation around that. It says it’s best to use abandonRows() for multiple rows. And call mod l.save after that to commit to the database. I did that but it’s not committing the deletion.

Are you saying I should call markrowfordeletion, deleteRow() then call save?


Forum|alt.badge.img+2

Hello Jili,

AbandonRows() - will empty your model, meaning it will sweep off all data including Id’s of records in model, in order to delete records from database, we need to supply Ids.
 
Try as shown below:

var $ = skuid.$;

$.each(myModel.getRows(), function(){    
      myModel.deleteRow(this);
});

myModel.save();


Hope this helps!


Forum|alt.badge.img+8
  • Author
  • July 10, 2024

Using deleteRow instead of abandonRows worked. Thanks!


Forum|alt.badge.img+8
  • Author
  • July 10, 2024

deleteRow() and model.save is the correct way to delete from database. Thanks.