In Form Editor, “null” isn’t the same as NULL (huh?)

Level 10 - Community Moderator
Level 10 - Community Moderator

You don’t really know Marketo forms until you grok the differences between these 3 form field setups:




Setup #1



This first screenshot is what you get simply by adding a field and flipping its type to Hidden.The field is set to have an empty string as the default value, as you can see in the field details:



However, if you don’t pop up the details, Marketo displays the default value as the string “null”. This can be confusing, as the actual value sent is the empty string “”. (Remember that form fields are always sent as strings, regardless of the back end datatype.)


What’s the difference? It’s huge! Sending an empty string does not change the existing value in the Marketo database. Sending the magic string “null” (or capital “NULL” or “Null”, it’s not actually case-sensitive) erases the current value.[1]


So at a glance, you might think the hidden field is going to nullify/empty out the server value. But in fact it won't affect the server value at at all.


Notably, if you switch the field to use Auto-Fill and then try to switch it back to a constant value, the value can’t be empty!



Unless you remove the field from the form and add it again, the setup that seems like it’ll send “null” but actually sends an empty string “” can’t be reproduced.


Setup #2



This next one is a hidden field set to Autofill from a query parameter named utm_medium, with no default value:



Note that in this case, the form does not appear to be sending the value
“null” (which is good, ’cuz it’s not!).


Rather, in the main Form Editor view there’s no mention of the default value either way. When you pop up the details, you see the default value is the empty string “”.


So the form will not update the server value unless the query parameter is non-empty. If the param is missing or empty[2], an empty string is sent, and the server disregards it.


Setup #3



This last example is a hidden field that's set to Autofill from the query param utm_medium, falling back to the string “NULL” if the param is missing or empty:



Therefore the form can either fill in the server value or empty it. If the param has a non-empty value, it sends that value. Otherwise, it sends “NULL”, which the server interprets as “erase the current value”.


As you might have figured out, this is the setup you typically want for multitouch tracking.


You don’t want old UTM values to stick around and get mixed together across form fills. Rather, you want to make sure all UTM fields are updated, as a group, by any form fill.



[1] Contingent on Block Field Updates allowing the change, of course.


[2] The query param utm_medium is present in these two URLs, but has an empty value:


Marketo happens to treat those URLs the same as if the param were completely missing, like in:


Yet other apps may draw a distinction. The URLSearchParams spec dictates that missing query params have the implicit value null (not a string “null”, an actual null), while params that are present always have a string value, including an empty string. Tricky!