I noticed there wasn’t a complete script available in the forums that allowed for this, so I wrote one. This can also be used to copy selected rows in any models table to another model.
The source model in this example is LineItemsBundle, which is conditioned and queried using action items. (Activate Condition & Set Value, Query Model, Open Drawer). It didn’t work particularly well using Before Load actions, so manual actions were used instead. The destination model is QuoteLineList. Selected rows from within the draw will be added to the QuoteLineList model with variables set in the script and then saved. Hope this helps!
var params = argumentse0],<br /> $ = skuid.$, models = skuid.model.map(); // grab ids of all selected rows var Ids = skuid.$.map(argumentse0].list.getSelectedItems(), function(item){ return item.row.Id; }); // model to add seleted rows from var bundlelines = skuid.model.getModel('LineItemsBundle'); // model to add to var quotelines = skuid.model.getModel('QuoteLineList'); // for each selected row, add a new row $.each(Ids, function(){ var currentId = this; // get selected row data var bundleRow = bundlelines.getRowById(this); // set variables for selected row field(s) var itemId = bundlelines.getFieldValue(bundleRow, 'Item__r.Id'); var itemQuantity = bundlelines.getFieldValue(bundleRow, 'Quantity__c') var bundleName = bundlelines.getFieldValue(bundleRow, 'Bundle_Name__r.Name'); // create new row with selected row variables var quotelinerow = quotelines.createRow({ additionalConditions: n {field: 'SCMC__Item_Number__c', value: itemId, operator: '='}, {field: 'SCMC__Quantity__c', value: itemQuantity, operator: '='}, {field: 'AC_Bundle_Group_Name__c', value: bundleName, operator: '='} ] }); }); // save updated model quotelines.save({callback: function(result){ if (result.totalsuccess) { //console.log(quotelines); } else { console.log(result.insertResults); console.log(result.updateResults); console.log(result.deleteResults); } }});<br />