Passing CheckBoxGroup.selectedValues to parameter in query

I have a checkgroupbox and I would like the value of the selected box to be used in a query. The problem is that this value is in an array so I get with checkboxgroup.selectvalues a response of this type [“value”]. I use one and the same query for all options, only the table name changes depending on the value of the selected option
I don’t have enough knowledge in js to use only the index value of the selected option

Thanks for your help


It sounds like you might be looking for something more like the Select Widget. This way, your options will start in a similar format that you’re currently using:

    {"label": "Red", "value": "RED"},
    {"label": "Blue", "value": "BLUE"}

With the Select Widget, you will be able to have the user select any one option, and you can access the name or value of their choice with:

{{ Select1.selectedOptionLabel }} => "Blue"
{{ Select1.selectedOptionValue }} => "BLUE"

Would this help? If you need to be able to select multiple options at the same time, then it sounds like you might need to loop through the array of selected options and perform a query for each one (indeed you can do with the CheckboxGroup Widget, like you are currently using). This may require a bit more difficult code syntax, though, just as a heads-up.

Something like this (this might not be exact, but it’s an idea):

// In a JSObject
export default {
    performSelectedQueries: async () => {
        const selectedValues = CheckBoxGroup.selectedValues // looks like ["RED", "BLUE"]
        selectedValues.forEach( (value) => {
            await storeValue("currentValue", value) // saving this within the appsmith store to be used within the query
            // if you need data from the query, capture it here. Maybe something like:
            // await storeValue(value, // use it elsewhere with or

And then in your query, it might look like:


For each of the CheckBoxGroup selected options, your function will store the option’s value in, and then it will run the query with that value, and then move on to the next.

I hope this helps!


Thank you very well for your explanation, it was very helpfull

1 Like