Javascript: Create new row and set Lookup field to reference an unsaved object (SKUID Temp ID, not S

Hi Anna,

So you’re saying that if I use skuid.model.save(ArrayOfBothModelsToSaveSimultaneously) it won’t give the invalid ID error?

I’ve run through a test of this and it appears to work!!

var params = arguments[0], $ = skuid.$;
var am = skuid.model.getModel('AccountModel');<br>var cm = skuid.model.getModel('ContactModel');
var models = [];
models.push(am);<br>models.push(cm);
$.when(am.createRow({doAppend: true, additionalConditions: [<br>{field: 'Name', value: 'TEMPVARTESTACCOUNT'}<br>]<br>})).done(function(){<br>&nbsp; &nbsp; var amRow = am.getFirstRow();<br>&nbsp; &nbsp;&nbsp;<br>$.when(cm.createRow({doAppend: true, additionalConditions: [<br>&nbsp; &nbsp; {field: 'LastName', value: 'TEMPVARTESTER'},<br>&nbsp; &nbsp; {field: 'AccountId', value: am.getFieldValue(amRow,'Id',true)}<br>&nbsp; &nbsp; ]<br>&nbsp; &nbsp; })).done(function(){<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; skuid.model.save(models, {rollbackOnAnyError: true,callback: function(result){<br>&nbsp; &nbsp; &nbsp; &nbsp; console.log('SAVE RESULTS:');<br>&nbsp; &nbsp; &nbsp; &nbsp; console.log(result); //Success!!<br>&nbsp; &nbsp; }});<br>&nbsp; &nbsp; });<br>});

It also appears that if I run an action sequence (UI editor) based save on both models simultaneously that is working as well. This is very strange though because I was using an action sequence based save on all models simultaneously before when I first created this forum thread and it was giving me the invalid Id error; now that I try coding it out in my test example it seems to not be having that problem. Very peculiar. It’s been a while since I had this error in my original code and I’ve since reworked it using a different strategy for saving / relating items. I’ll let you know if I can reproduce my original issue as we’re coding our new project up and do some more testing around it, otherwise it appears this strategy works! Thanks!