Custom boolean values (checkbox)

Hi everyone,

Please would you assist if possible?

At the moment I have multiple checkboxes in a form. I am using this form submission to trigger a zapier automation, which in turn creates a lead in my CRM.

The problem is that the WIX form is sending a text value of “checked” or “unchecked” through to the CRM and both values are being recognised as true on in the CRM. (these values can also be seen on the form submission email)

Is there a way to change this text to a different value for true or false, for example “yes” if true and “no” if false.

Alternatively is there a way for there to be no text value/an empty field if the checkbox is not checked

If this is possible, please would you reply with the code

Thank you very much

When you use the checkbox you will just get the boolean value of true or false depending on whether the user ticked the checkbox or you have it setup as default etc.
https://www.wix.com/corvid/reference/$w.Checkbox.html#checked

checked
Sets or gets whether a checkbox is checked.

Description
Setting the checked property to true places a check in the checkbox. Setting it to false removes the check from the checkbox.
Getting the checked property returns whether the checkbox is checked or unchecked.

If you are wanting to get some sort of value from that checkbox, then you need to look at using code to add the value as shown here.
https://www.wix.com/corvid/reference/$w.Checkbox.html#value

value
Sets or gets a checkbox’s value.

Description
The value property is not related to whether the checkbox is checked or not. To determine the checked status of a checkbox, use the checked property.

The value property is used for storing a value that is associated with the checkbox.
It is not considered when evaluating the checkbox’s validity and it does not trigger an onChange event when the value is modified.

Even if a checkbox is connected to a dataset, its value property is not related to the value of the collection field it is connected to. The field’s value is determined by the checkbox’s checked property.

Nayeli (Code Queen) has a tutorial about combining checkboxes and their values here.
https://codequeen.wixsite.com/checkboxes
How to combine values in Wix Code - Checkboxes Tutorial

You can look at her code example and modify it to suit your own needs and to collect the value in your dataset and use that instead of the checkbox boolean field

Otherwise, you can look at using checkbox groups which give the user multiple choice and you can set them up to have a label which is shown on the page and a value that is added to the dataset on submit
https://www.wix.com/corvid/reference/$w.CheckboxGroup.html

CheckboxGroup
Checkbox groups are used for selecting any number of the given options.

Checkbox groups consist of a list of options . Each option contains a label, which is what the user sees, and a value, which is what is used in code and stored in your collections.

Hi GOS,

Thanks for your reply,

What I’m trying to say is that the WIX form is actually sending the words “checked” and “unchecked” to Zapier. It does this as well when you recieve the form submission via email.

I need the form to send the words “true” or “false” OR "yes or “no” OR “1” or “0” as these are recognised by Zapier and my CRM as true or false values.

When the words “checked” or “unchecked” are sent, they are recognised as random values and therefore mark all the CRM’s corresponding check fields as true.

I have attached a sample form to show how the values are coming through on the email notification, these same values without the icons are being pushed to Zapier.

Matt

Hey Matt,

If you want to change a checkbox value then do something like this:

if ($w("#checkboxBantryBay").checked) {
$w("#checkboxBantryBay").value = "Yes";
} else {
$w("#checkboxBantryBay").value = "No";
}

Now you should place this inside a function or handler. Not sure how you set up your form, but if you are sending/saving the data collected with a submit button, then you could use this snippet within its onClick() event. Another scenario could be one in which you use an onChange() event for each of your checkboxes, and place this code inside those events.

Regarding Zapier or Wix forms, I’m not familiar with them, but surely they would let you pass the checkboxes values according to your needs.

Good luck!

2 Likes