Here's my dilemma, I want my opt-in field on my forms to be a String datatype not a boolean, because I want to know who hasn't opted in or opted out yet. So I add a field of type Checkboxes on a form, but it only has one value and that value stores a "yes" if the box is checked. My custom field is a datatype of String.
If someone submits that form without checking the box it stores a value of "no" as if it's a boolean field. I don't want it to change the field value at all if someone doesn't check the box. This is messing up my GDPR and CASL opt-out compliance time/date stamps. I want the value to be NULL if there's no action.
I am assuming I will have to add a second checkbox with a value of "no" and hide it with a display:none or something. Is this the only way around this?
Why does the Checkboxes field type act like a boolean if you only give it one value? Bueller? Bueller? Anyone?
Solved! Go to Solution.
This is in fact a bug in the forms library.
You're absolutely right that it's not the intended behavior with Checkboxes fields, which should assemble a semicolon-delimited string containing values only of checked inputs. Unchecked inputs should not be included in the string, and a synthetic string value "no" should not be created.
The reason you're seeing the bug is that you're using the literal server value "yes" in lower case. If you use the server value "YES" in upper case (or "yeah" or another meaningful string) the bug isn't triggered.
I want the value to be NULL if there's no action.
Actually, you want the value to be the empty string if there's no action. The four-letter string "NULL" will empty the stored value, while the empty string will not change the stored value. If you don't use literal "yes" then you'll get the expected outcome.
Hi, by opt-in field are you referring to the default Marketo "unsubscribed" field? or did you create a custom field? And is the field type in admin=>field management for this field "string"?
Going by what you have shared, if the field type is still boolean in field management, no matter what type of field you use in a form, the data will adhere to standards of the field type set in field management. And boolean fields can only have 2 options - 0 or 1 / Yes or No / True or False. Empty/blank/null is different to false/no/0
Create and use a custom field that's a string type to achieve what you want. Just bear in mind, if a value already exists in the field and the field is submitted again "unchecked", Marketo won't clear the field. You'll need to force the field to pass a NULL value through to clear the field.
It's a custom field with the datatype of String. I guess that wasn't clear in my original post.
Please confirm if I'm understanding correctly:
Field has never been checked before:
Initially "NULL"
Checked:
Yes/True/1
Unchecked after being checked:
No/False/0 => but you don't want this. You would like it to still be Yes/True/1
One way to achieve the above is with a smart campaign + a proxy field:
Create another field to be used in the form (a proxy field and this can be a boolean), and switch it with the opt-out field in your form
Smart campaign Smart list
Trigger: Data value changes "proxy field"
New value "True"
Smart campaign Flow
Change data value with choice
Choice 1 if "opt-out" is empty
attribute "opt-out" new value "Yes"
default choice do nothing
Can only run through once
This cannot be a "run through once" deal because people need to be able to opt in and opt out as many times as they want.
This is in fact a bug in the forms library.
You're absolutely right that it's not the intended behavior with Checkboxes fields, which should assemble a semicolon-delimited string containing values only of checked inputs. Unchecked inputs should not be included in the string, and a synthetic string value "no" should not be created.
The reason you're seeing the bug is that you're using the literal server value "yes" in lower case. If you use the server value "YES" in upper case (or "yeah" or another meaningful string) the bug isn't triggered.
I want the value to be NULL if there's no action.
Actually, you want the value to be the empty string if there's no action. The four-letter string "NULL" will empty the stored value, while the empty string will not change the stored value. If you don't use literal "yes" then you'll get the expected outcome.
Fantastic. So I can use anything but yes in lower case. Brilliant.