6 Replies Latest reply on May 7, 2018 9:22 AM by Kelly Horton

    Why does the Checkboxes (plural) form field act like a boolean?

    Kelly Horton

      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?

        • Re: Why does the Checkboxes (plural) form field act like a boolean?
          Jay Jiang

          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.

          • Re: Why does the Checkboxes (plural) form field act like a boolean?
            Sanford Whiteman

            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.

            4 of 4 people found this helpful