How to make checkboxes dynamic in POST request

Hi, I have a screen with checkboxes.
In post request got an Error: field: day checkbox field value must be a boolean
Invalid JSON: SyntaxError: Unexpected token “$”, … ‘Day’: $(day)," … is not valid JSON.
To solve this I changed the coding as

At first;
“Day”: “${day}”,
“Evening”: “${evening}”,
“Night”: “${night}”

after changing to boolean:
day: true,
evening: true,
night: true

API request succeeded but now the checkboxes are hard coded to true and are always checked in aitable. I want them to be dynamic for user input.
Also the checkboxes are not responsive to clicks when the screen is “played” to test.

please guide me and help solving these issues

Thank You.

1 Like

Hey @Shrut_Patel It seems for me that the variable you using is simply not a boolean.

So be sure just when creating a variable, that it’s from the type “bool”, then connect it to “value” of the checkbox.

if you still have a problem please let me know

Hi @anas I already had selected the “bool” type for the checkbox variable as you suggested, but the checkbox is still not dynamic and not responsive when I try to click it during “play” to test. Please help me solve this issue.
I want users to be able to check these checkboxes so that their responses can be recorded in the AItable.ai datasheet.

Thank you.

Hey! After connecting the varibale to the value, you also need to add a function to On Change.

On Change get called when user click on the checkbox. You need inside to get the value, which is the new value of the checkbox after user clicking, set it to be the varaible you created before, and call refresh to update the UI.

Here’s more on how to do so:

1 Like

Hi @anas, thankyou for your assistance with setting dynamic checkboxes, but now I need help with setting up the API request for the screen.
After making the checkboxes dynamic as you showed, I set the variable and refreshed. Now I’m having an issue where the checkbox data is not being sent to the AItable. The text data is sent, but not the checkbox data.

Here’s how I’ve set up the API request on one of the screens:

Here is the screen I’m referring to:

I’d like to send all this information (text and checkboxes) filled out by users to the datasheet in the table.

Hey @Shrut_Patel I just see that you aren’t passing the bool variables to the API body. So the steps are as follows:

  • Create a variable of type bool that is connected to value in the checkbox
  • Add the function on Change where you set the variable created before, to the value you recieve from the function. This will allow setting the new value of the boolean when user click on it
  • in the body, create a parameter of type bool as well and use it inside the body by using $
  • In Circuit, under an event like button click, add the API POST request node. You will see the bool parameter created earlier for the request. Connect it to the variable that you created in the first step

That’s it. If it wasn’t clear enough please let me know :slight_smile:

it worked, thank you for the help!

1 Like

Hi team,
Faced another issue with checkboxes, dropdown and api request.
In the screen there are three checkboxes and a dropdown menu.

checkboxes:
Each checkbox is connected to a boolean variable, and the onChange is set to refresh based on the checkbox selection. The boolean variables are linked to parameters in the API request which are also bool type.

dropdown menu:
Initially, I wanted to populate the dropdown from an API, but the items weren’t responsive (I posted a question regarding this, but didn’t get a reply yet).
So, to continue, added some items manually to the dropdown and make the dropdown value a variable. I haven’t set up any onChange logic for the dropdown.

The issue is - All the Text data is being sent correctly to the aitable, but the checkbox values are showing the default (not the user’s selection).
The dropdown data sent to aitable is showing ‘first’, no matter what the user selects.

Can you help me fix this as soon as possible? I’d appreciate any advice!

Thanks!

Hey @Shrut_Patel

Thanks for posting here and appoligoze if it took some time to come back to you. We have been working on the 2.0 version that will change alot of things on how to build, including the logic part. (Should be way easier ;))

Anyway, for the logic you did it look correct for me to update the checkbox. It look like Value for the checkbox might be connected to another variable (or you are setting here another boolean rather than the one connected to Value), or that there’s another logic that alternate the bool value as well.

Can you share with me the projectID so I can see why?

For the Dropdown menu, it’s in BETA and we will do changes on how it works to simplify it, but basically I guess you are saying that the text doesn’t change and it always shows first because you are using the value field in the DropDownMenuItem, but that’s the “value” of the item not the display text.

On the outline panel you will see the actual widgets (which are text widgets) under the dropdown and chaning the text there will be the action to change the text displayed.

If you wish to dynamically change the text (Connect them to a list of String) then connect items inside the DropDownMenu to a list of String, then go to the Text widget below it and for the text field connect it to element which is the signle element (String) coming from that list.

Also, inside the widget, scroll to the end and connect value as well to element. This will make each item text and value hold a single string from the list. When user uses the dropdown, the value of the selected item will be the same as the text itself, so you can use that to perform some logic.

Hopefully it’s clear enough, if not let me know!

If you find it difficult to get around with, I would advice you to sign up for Nowa 2.0 since it will be easier to use than the one online right now.

Hope you get a huge success for your clients!

Hi, so for the checkbox here, i have set the same value in the onChange logic, as shown below
checkbox value

Here is the projectid - Nowa
please check this and let me know what the issue is.
Thank you

for the dropdown, here is how i have connect the items and the text widget to the list;


is this way correct, if not please help me correcting it.
Also i want to send the selected item to a datasheet via api, using a variable in the value of dropdown menu would help this?