Create multiple objects from multi-select


I have a post API input that expects an object (or multiple objects) formatted in the following way:

I am using the multi-select which is bound to a collection in my Xano project to grab the ID # I need. I am only able to take the first item in my multiselect and create a properly formatted object out of it.

Screenshot 2023-06-02 at 11.00.34 PM

How do I set this up to where if I have multiple items in my multi-select, I can create multiple objects for binding with my API?

On the front-end, I would use javascript action with a one-liner like:

[green box with "input multiselect - currentSelection"].map((value)=>({equipmenttypes_id: value}))

Adding a bit of JS to crack data manipulation problems is often what we do as part of working on the hardest 5% at State Change Pro forums and daily office hours.

1 Like

Thank you for helping and I’ve seen your posts on twitter :slight_smile:

I’m getting undefined when running this arrow function. I have values in my multi-select array as you can see on the right. Any additional help would be appreciated. In the meantime, I will try to run some functions on the backend in Xano and see if that turns out easier.

That return is making a hash of things. By being on a line by itself, it is saying “return the thing after the return word”. And since nothing follows it, it is returning nothing. And Javascript for nothing is “undefined”.

To solve this, put the return keyword in front of your green block so it reads:

return [green box with "input multiselect - currentSelection"].map((value)=>({equipmenttypes_id: value}))

Work any better for you?


It works! :sob:

You could also do it in no-code using the map formula :wink:

How did you manage to get the fat arrow to work without the formulate editor intervening? When I type ‘=’ or ‘>’, the formula editor reformats those two characters.

In the upper left of the box you can toggle between formula mode and JavaScript mode. The latter is what you want to implement lambdas and closures.

1 Like