How to pull Column value of selected rows in multi select table into an Array

Hi All,

I'm looking for a simple way to pull all of the values from a particular column based on the rows I've selected in a multiselect table and put them into an array that I can pass to my query.

For example, I have this table here:
image

I want to be able to pass the two Product IDs as an array to my query without having to manually build an array every time I select or deselect a row.

For example when I use selectedRowKeys it does exactly what I want except its the value is the Keys where the value I want is "Product ID".

{{(tblNSLineItemFulfillments.selectedRowKeys)}} gives me the keys in an array.
image

Welcome to the forum!
In a transformer do the following

return {{yourTableName.selectedRows}}.map(it => {
return {
product_id: it.product_id, //where product_id is the underlying name of the column not the Label
}
})

product_id can be the name of the key you need in the query

Thanks so much this has got me really close. How do I make sure i'm only pulling the values, of the key value pair?
If you se see here its repeating the key "product_id" where all I want is the values in an array:

image

For example the payload should be {"product_ids":["1234567","2345678"]}

Create a transformer and name it yourTransformerNameAsNeeded and populate it with
const product_ids = [];
return product_ids.concat({{yourTableName.selectedRows}}.map(it =>(it.product_id)))

Next create a variable named product_ids and set the Default value to yourTransformerNameAsNeeded.value

Then use the variable product_ids in your query

1 Like

This worked beautifully! Thank you!