What kind of javascript object do i get in the args of a snippet that is used for a mass action ?

Hi Ken, For others that are reading this, here are a few examples of how to use a Mass Action to retrieve the selected items and perform an action on all selected rows: How to add a “Marketo Send Email” mass action to a Skuid table Drawloop mass mail merge But as far as technically, what is passed into a Mass Action Snippet, you are passed a JavaScript object with the following parameters:

  • model - the Table’s Model
  • list - the underlying skuid.ui.List object for the Table
the list parameter here is the most useful. While we do not have official documentation on skuid.ui.List yet, one of the supported methods of List is getSelectedItems() which returns a reference to the skuid.ui.Item objects that have been selected. Each skuid.ui.Item has a reference to its associated Model row, so here are some examples of code which you can use to get at the selected Rows: Example 1: Build an Array of the Model Rows corresponding to the selected Items in a Table

// Get the Ids of the selected items as an Array var selectedRowsArray = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ return item.row; }); 

Example 2: Build an Array of the Ids of the rows corresponding to the selected Items in a Table, then join them into a comma-separated String of Ids

// Get the Ids of the selected items as an Array var idsArray = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ return item.row.Id; }); // Convert this array to a comma-separated String var idsString = idsArray.join(','); 

Example 3: For each selected Contact in a Table, create a corresponding CampaignMember record for a specified Campaign

// Here, our Table is on a Contacts Model var campaignId = '701U00000002OS3'; var CMModel = skuid.model.getModel('CampaignMembers'); // Create a new Campaign Member for each selected Contact skuid.$.each(arguments[0].list.getSelectedItems(),function(i,item){ var newCM = CMModel.createRow(); CMModel.updateRow(newCM,{ 'ContactId': item.row.Id, 'Contact': item.row, 'CampaignId': campaignId }); }); CMModel.save();