I start with an empty model. I create a row. I save the model. Then when I use getFirstRow(), it returns undefined. It looks like mC.data.length = 0, even after I’ve created a row and saved. What am I doing wrong here?
I tried re-setting the value for the model variable (mC) after the save, but it still shows data.length = 0.
Here’s my code:
// Schedule -- new case <br> var //mP = skuid.$M('Patient'),<br> mC = skuid.$M('Case'),<br> mA = skuid.$M('Open'),<br> rA = mA.getFirstRow(),<br> $ = skuid.$,<br> dfd = new $.Deferred();<br> <br> //Create Patient Case<br> $.blockUI({<br> message: 'Creating Patient Case...'<br> });<br> <br> mC.createRow({ <br> additionalConditions:o<br> {field: 'Case_Type__c', value: rA.Case_Type__c},<br> {field: 'LMP__c', value: rA.LMP__c},<br> {field: 'Preliminary_AVR__c', value: rA.Preliminary_AVR__c},<br> {field: 'Payment_Option__c', value: rA.Payment_Option__c},<br> {field: 'Permission_to_Call__c', value: rA.Permission_to_Call__c},<br> {field: 'Permission_to_Text__c', value: rA.Permission_to_Text__c},<br> {field: 'Permission_to_Leave_Message__c', value: rA.Permission_to_Leave_Message__c},<br> {field: 'Referral_Source__c', value: rA.Referral_Source__c}<br> ]<br> });<br> <br> //Save Case model<br> $.when(mC.save())<br> .done(function(){<br> //Set Interaction Patient_Case__c to case just created, and query Interaction model<br> mC = skuid.$M('Case');<br> var rC = mC.getFirstRow(),<br> mI = skuid.$M('Interaction');<br> mI.setCondition(mI.getConditionByName('CaseID'), rC.Id);<br> $.when(mI.updateData())<br> .done(function(){<br> dfd.resolve();<br> })<br> .fail(function(){<br> console.log('Interaction model query failed.');<br> dfd.reject();<br> });<br> dfd.resolve();<br> })<br> .fail(function(){<br> console.log('Case model save failed.');<br> dfd.reject();<br> });<br> return dfd.promise();