Using checkboxes to update field to null value

Using checkboxes to update field to null value

I'm creating a subscription center form where users can select checkboxes for types of communications they want/don't want to receive, which updates a "Preference" custom field.  I wanted to build this so that if they uncheck all the boxes, they will update the preference field to a null value, which would in turn trigger a Smart Campaign that flags TRUE for the Unsubscribed Lead system smartlist, but not if there is a value in the field.

The problem is, the checkboxes work perfectly fine when 1 or more value is selected, but leaving all values empty will merely result in that field not being updated, rather than being updated with a null value.  That makes sense and is certainly how I would expect it to work, but in this case it is not what I'm looking for.  Does anyone have ideas on how a field could be updated with a null value when nothing is selected?

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Using checkboxes to update field to null value

While there are several approaches, an easy one is demoed here.

Rather than trying to act on an empty value, include a hidden checkbox that represents "none of the above" and trigger on that value.  In this demo the value is "U" (for Unsubscribe).  The JS that accompanies the form takes care of selecting the hidden value if none of the visible values are checked, and vice versa.