Perhaps I found the answer… thanks to Pat for undergoing the agony for the rest of us learners.
Here’s my new code:
var model = argumentse0].model, row = argumentse0].row, <br> $ = skuid.$;<br>var mA = skuid.$M('AllAppointments');<br>mA.createRow({additionalConditions:o<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>mA.save();<br>$.when(mA.save())<br> .done(function(result){<br> if (result.totalsuccess) {<br> mA.setCondition(mA.getConditionByName('ThisOne'), mA.getFirstRow().Id);<br> mA.updateData();<br> } else {<br> console.log('something went wrong...');<br> console.log(result);<br> }<br> })<br> .fail(function(result){<br> console.log('there was a really bad problem, like connecting to the server');<br> });
I typically use this jquery when function. Also, you’d need to do set a deferred promise if there other actions following this in an action framework.
var model = argumentst0].model, row = argumentst0].row, $ = skuid.$; var mA = skuid.$M('AllAppointments'); mA.createRow({additionalConditions:s {field: 'Start__c', value: row.Start__c}, {field: 'End__c', value: row.End__c}, {field: 'Room__c', value: row.Room__c} ]}); model.deleteRow(row); $.when(mA.save()) .done(function(){ mA.setCondition(mA.getConditionByName('ThisOne'), mA.getFirstRow().Id); mA.updateData(); }) .fail(function(){ console.log('Something went wrong querying ProposalLineItemForCurrentTask model.'); dfdTask.reject(); });<br />
Nice. What does a deferred promise look like?
I’m looking at this: https://community.skuid.com/t/mixing-actions-and-snippets
But I’m not quite sure how to implement.
var model = arguments[0].model, row = arguments[0].row, $ = skuid.$, dfd = new $.Deferred(); var mA = skuid.$M('AllAppointments'); mA.createRow({additionalConditions:[{field: 'Start\_\_c', value: row.Start\_\_c}, {field: 'End\_\_c', value: row.End\_\_c}, {field: 'Room\_\_c', value: row.Room\_\_c}]}); model.deleteRow(row); $.when(mA.save()) .done(function(){ mA.setCondition(mA.getConditionByName('ThisOne'), mA.getFirstRow().Id); $when(mA.updateData()) .done(function(){ dfd.resolve(); }) .fail(function(){ console.log('Something went wrong querying ProposalLineItemForCurrentTask model.'); dfdTask.reject(); }); }) .fail(function(){ console.log('Something went wrong querying ProposalLineItemForCurrentTask model.'); dfdTask.reject(); }); return dfd.promise();
Quite welcome. Those two things, jquery when and deferred, have taken me a long way in working with javascript for skuid purposes.
@skuid employees,
Can we add this to documentation?
“You’d need to do set a deferred promise if there are other actions following this in an action framework.”
Thank you Pat. How did you figure this out?
I set to learning jquery the hard way. Lots of trial and error. My first post in this thread was the result.