Skip to main content
Nintex Community Menu Bar

Copy/add selected rows within a drawer from one model to a different model

  • June 21, 2024
  • 5 replies
  • 0 views

Forum|alt.badge.img+1

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 = arguments[0],<br /> $ = skuid&#46;$, models = skuid&#46;model&#46;map(); &#47;&#47; grab ids of all selected rows var Ids = skuid&#46;$&#46;map(arguments[0]&#46;list&#46;getSelectedItems(), function(item){ return item&#46;row&#46;Id; }); &#47;&#47; model to add seleted rows from var bundlelines = skuid&#46;model&#46;getModel('LineItemsBundle'); &#47;&#47; model to add to var quotelines = skuid&#46;model&#46;getModel('QuoteLineList'); &#47;&#47; for each selected row, add a new row $&#46;each(Ids, function(){ var currentId = this; &#47;&#47; get selected row data var bundleRow = bundlelines&#46;getRowById(this); &#47;&#47; set variables for selected row field(s) var itemId = bundlelines&#46;getFieldValue(bundleRow, 'Item__r&#46;Id'); var itemQuantity = bundlelines&#46;getFieldValue(bundleRow, 'Quantity__c') var bundleName = bundlelines&#46;getFieldValue(bundleRow, 'Bundle_Name__r&#46;Name'); &#47;&#47; create new row with selected row variables var quotelinerow = quotelines&#46;createRow({ additionalConditions: [ {field: 'SCMC__Item_Number__c', value: itemId, operator: '='}, {field: 'SCMC__Quantity__c', value: itemQuantity, operator: '='}, {field: 'AC_Bundle_Group_Name__c', value: bundleName, operator: '='} ] }); }); &#47;&#47; save updated model quotelines&#46;save({callback: function(result){ if (result&#46;totalsuccess) { &#47;&#47;console&#46;log(quotelines); } else { console&#46;log(result&#46;insertResults); console&#46;log(result&#46;updateResults); console&#46;log(result&#46;deleteResults); } }});<br />
This topic has been closed for replies.

5 replies

Forum|alt.badge.img
  • New Participant
  • June 21, 2024

Adapted this snippet for use in transferring Opp LineItems to the Quote being created. Below are the changes I made to the snippet. If anyone’s having issues with quotes in Skuid shoot me a message and i’ll send you a sample page I put together. var params = arguments[0], $ = skuid.$, models = skuid.model.map(); // grab ids of all selected rows var Ids = skuid.$.map(arguments[0].list.getSelectedItems(), function(item){ return item.row.Id; }); // model to add seleted rows from var bundlelines = skuid.model.getModel(‘LineItems’); // model to add to var quotelines = skuid.model.getModel(‘QuoteLineItems’); // 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, ‘PricebookEntryId’); var itemQuantity = bundlelines.getFieldValue(bundleRow, ‘Quantity’) var bundleName = bundlelines.getFieldValue(bundleRow, ‘UnitPrice’); // create new row with selected row variables var quotelinerow = quotelines.createRow({ additionalConditions: [ {field: ‘PricebookEntryId’, value: itemId, operator: ‘=’}, {field: ‘Quantity’, value: itemQuantity, operator: ‘=’}, {field: ‘UnitPrice’, value: bundleName, operator: ‘=’} ] }); });


Forum|alt.badge.img+1

Wow, thanks for sharing your snippets with the community, Oliver and Erik!

Karen


Forum|alt.badge.img+1

does that offer still stand?


Forum|alt.badge.img
  • New Participant
  • June 21, 2024

Probably still have the sample page on file, i’ll check and see if I can find it 


Forum|alt.badge.img+1

hi erik, did you happen to find that page?