I have a model that, when a new row is added, sets 2 default values through the model Actions. I also need to be able to duplicate a record in the model, but I can’t use the “clone” button option because I need to do multiple things in the process. I have a button that changes a value in the current record (deactivate), and then runs a custom snippet to add a new row and use the values from the pre-existing row (see code below). The problem I’m seeing is that the 2 default values established in the model Actions seem to override the JS and the values I need. Can the code below (I got it from an older post) be modified to override the defaults? Are there other options I’m missing?
var params = arguments[0], row = params.item.row,
model = params.model,
$ = skuid.$;
var newRow = model.createRow();
if (row) {
$.each(row,function(fieldId,val) {
if ((fieldId != ‘attributes’) && (val != null) && (fieldId != ‘Id’)) {
var modelField = model.getField(fieldId);
if ((typeof val === ‘object’)
|| (modelField && modelField.createable)) {
model.updateRow(newRow,fieldId,val);
}
}
});
}
Question
Clone record without using Clone button...
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
