getSelectedItems() not working on Wizard?

I’m new to Skuid, and trying to figure out why this code is working fine as a mass action on a table, but shows arguments[0].list as undefined when used as an action on the Next Step button of a Wizard.

The table with the mass action is the same table in the first step in the wizard. If the arguments aren’t getting passed properly to the Wizard, how can I make that happen?

Here’s the code:

var idsSelected = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ return item.row.Id; }); var ids=idsSelected.join(","); window.alert(ids);

Hi Samuel

Try to run this:

var model = skuid.$M('modelName'),<br> ids = [],<br> $ = skuid.$;<br> <br>$.each(model.registeredLists,function(){<br> skuid.$.map(this.getSelectedItems(),function(item){ <br> ids.push(item.row.Id);<br> });<br>});<br><br>ids.join(',');<br><br>window.alert(ids); 

The Snippet you were using previously relied on a List to be passed in context — which you will get if you’re in a Mass Action Snippet. However, from a Wizard Step Button, there’s no “context” List, so arguments[0].list is not going to work. What you can do instead is this: 

1. Find (and/or modify) the Unique Id of the Table from which you are trying to get selected items. So for example let’s say its Unique Id is “MyTable”.
2. Modify your Snippet to be this:

var TABLE_UNIQUE_ID = ‘MyTable’;
var list = skuid.$(‘#’+TABLE_UNIQUE_ID).data(‘object’).list;
var idsSelected = skuid.$.map(list.getSelectedItems(),function(item){ 
   return item.row.Id;
var ids=idsSelected.join(“,”);

Thanks Zach - that’s helpful to know about arguments[0].list not working there. I used your code, but it’s still showing an error of “Cannot read property ‘data’ of undefined.”

Just to confirm, here’s the snippet code:

var TABLE_UNIQUE_ID = 'campaignSelectTable'; var list = skuid.$('#'+TABLE_UNIQUE_ID)'object').list;<br>var idsSelected = skuid.$.map(list.getSelectedItems(),function(item){&nbsp;<br>&nbsp; &nbsp;return item.row.Id;&nbsp;<br>});<br>var ids=idsSelected.join(",");<br>window.alert(ids);

I made a copy/paste error — the “.element” in line 2 is not supposed to be there. I edited my answer above to remove this part.

Thank you Zach! That totally works. I’m trying to take those IDs and apply them as a value in a condition on another model, in the context of a wizard.

1: Select the Campaigns you want
2: Click Next Step, which runs a snippet which sends those Campaign IDs as the value to a condition on a CampaignMember model
3: On the next page, there is a table using the Campaign Member model, only showing Campaign Members whose Campaign IDs are in that set of Campaigns from Step 1

This would be awesome if we can make it happen in Skuid. I really appreciate your help here!