var params = arguments[0],
chosenRow = params.item.row,
classesModel = params.model,
$ = skuid.$,
teacherModel = skuid.model.getModel('Teacher');
classModel = skuid.model.getModel('Class');
var teacherRow = teacherModel.getFirstRow();
classesModel.updateRow(chosenRow,'Teacher__c',teacherModel.getFieldValue(teacherRow,'Id'));
classesModel.save({callback: function(result){
if (result.totalsuccess) {
classModel.updateData(); // THIS IS WHAT DOESN'T SEEM TO BE WORKING
} else {
console.log(result.insertResults[0]);
}
}});
Peter Bender, Champion
-
6,276 Points
Posted 5 years ago
-
9,264 Points
maybe try skuid.Model.updateDate([classModel])
it looks like its a generic function and not one that is called on an instance of a model.
I see that you're in Berkeley. Any chance you'd like to get together sometime. I'm at ken@8thfold.com/510.384.7321
Thanks
Ben Hubbard, Employee
-
12,530 Points
console.log('Got Here!'); console.log(classModel);inside your if(result.totalsuccess) block. And check to see if you see 'Got Here!' in your console.
Another thing that you might try is that there is a semi-colon after your definition of teacherModel instead of a comma. This is putting your classModel variable into the global scope instead of the local scope. Typically this wouldn't cause issues, but it does open up that variable to being overwritten in other areas.
Peter Bender, Champion
-
6,276 Points
Ben Hubbard, Employee
-
12,530 Points
Thanks
Moshe Karmel, Champion
-
8,646 Points
-
9,264 Points
Peter Bender, Champion
-
6,276 Points
Moshe Karmel, Champion
-
8,646 Points
Peter Bender, Champion
-
6,276 Points
Moshe Karmel, Champion
-
8,646 Points
Ben Hubbard, Employee
-
12,530 Points
You should be able to set both conditions on the Class model to "Filterable default on" and then give them names. Once you've done this, you can use the following code to update the conditions before you try to update the data.
// Get a reference to the condition that sets TeacherId var teacherIdCondition = classModel.getConditionByName('MyTeacherIdCondition'); // Get a reference to the condition that sets LastestClassId var latestClassIdCondition = classModel.getConditionByName('MyLatestClassIdCondition'); // Set your TeacherId condition classModel.setCondition( teacherIdCondition, teacherModel.getFieldValue(teacherRow,'Id') ); // Set your LatestClassId condition classModel.setCondition(Let me know if this works for you.
latestClassIdCondition, chosenRow.Id ); // Refresh your model now that you have the conditions set classModel.updateData();
Peter Bender, Champion
-
6,276 Points
Ben Hubbard, Employee
-
12,530 Points
skuid.model.updateData([teacherModel,classModel],function(results){
// Callback code goes here
});
However, you might run into some issues with your particular instance since you're kind of combining a create new page and a detail page at the same time. I think you'll run into issues with this if your id parameter is not set in your url. It should work correctly if that id parameter is set from the beginning though. I forget if you do a page redirect after the new teacher is created or not, but if you do, then you should be fine.