This is a continuation of this thread, but a separate problem.
Here’s my code (thanks for your help, Pat!)
var model = argumentst0].model, row = argumentst0].row, <br> $ = skuid.$,<br> dfd = new $.Deferred();<br>var mA = skuid.$M('AllAppointments');<br>mA.createRow({additionalConditions:s<br> {field: 'Start__c', value: row.Start__c},<br> {field: 'End__c', value: row.End__c},<br> {field: 'Room__c', value: row.Room__c}<br> ]});<br> <br>model.deleteRow(row);<br>$.when(mA.save())<br> .done(function(){<br> var rA = mA.getFirstRow();<br> mA.setCondition(mA.getConditionByName('ThisOne'), rA.Id);<br> $.when(mA.updateData())<br> .done(function(){<br> dfd.resolve();<br> })<br> .fail(function(){<br> console.log('something went wrong on query');<br> dfd.reject();<br> });<br> })<br> .fail(function(){<br> console.log('there was a really bad problem, like connecting to the server');<br> dfd.reject();<br> });<br>return dfd.promise();
I’m running this little beauty before a calendar popup.
However, the popup displays before I get to the first .done (and it has a whole bunch of row s, because the condition hasn’t been set yet).
Any idea what might be going on here?
To back up a bit, for those interested in the context (perhaps there’s a better way to do this whole thing).
I have two (relevant) event sources. One is a model for our master schedule, and one is a model for recurring events created based on that schedule. The latter basically only has fields for Start__c, End__c, and Room__c (the grouping field). I want to give the users same experience whether they click on an event that is in the Schedule model (AllAppointments above) or the Reoccurrence model. So, what this code is doing is getting the data from the row in Reoccurrence and creating a new row in AllAppointments instead. Then I’m showing the same popup on the AllAppointments model. But I need to be able to narrow down the model to just the fields for the row I created.
Does that make any sense?
Is there a better way to ‘combine models’ into one event source?
thanks!