Field values set in snippet are not getting saved either by save method or by button action

Hi,

I have a table mass action which opens a popup. In the popup,  I have a button which calls a snippet to update few fields on the selected rows. I am using save() method to save the model rows. Once saved, I am closing the popup but the problem is that save is not happening. I can see the unsaved fields with updated values after popup is closed.
I even tried to remove the same method from snippet and add it as an action but that too did not work. I do not see any error in console. Any help is appreciated.

Shalabh,

Would you share your snippet and the XML of your model.

One thing that may be affecting you is that the line to close the popup may be running before your save completes.  You can try wrapping your ‘close’ in a promise:

var model=skuid.model.map().NameOfModel;
$.when(model.save())<br>.done(function(){<br> console.log('Models Saved'); //close all popups skuid.$('.ui-dialog-content').dialog('close');

})

Thanks,

Bill

Bill,

I tried what you suggested but it did not help. I got the log “Models Saved” in console but record was still unsaved.
Here is my snippet:

var table = skuid.$C(‘approverTable’),
list = table.element.data(‘object’).list;
var $ = skuid.$,
ApprovalHistory = skuid.model.getModel(“ApprovalHistory”),
selectedItems = list.getSelectedItems(),
rowsToUpdate = {};
$.each( selectedItems,
function( i, item )
{
var row = item.row;
rowsToUpdate[ row.Id ] = {Approval_Status__c:‘Pending Approval’};
});
ApprovalHistory.updateRows(rowsToUpdate);
$.each( ApprovalHistory.data,
function( i, row )
{
if(ApprovalHistory.getFieldValue(row,‘Approval_Status__c’)===null){
rowsToUpdate[ row.Id ] = {Approval_Status__c:‘Consulted’};
}
});
ApprovalHistory.updateRows(rowsToUpdate);
$.when(ApprovalHistory.save())
.done(function(){
console.log(‘Models Saved’);
//close all popups
skuid.$(‘.ui-dialog-content’).dialog(‘close’)});

Here is the model xml:

Can someone please help me with this issue?

Shalabh,

I don’t see any problems with your code.  I did notice that your ApprovalHistory model does not include the ‘Id’ field.  I don’t think this is needed, but its an easy addition to see if it resolves your issue.

What version of Skuid do you have installed?

Thanks,

Bill