Forms API: Adding multiple checkbox values instead of overwriting


#1

I’m using the Forms API to submit a form which contains a “Multiple checkboxes” field. I want the values submitted to be added to the contact’s existing values for this field, instead of overwriting them.

For example, if the contact has values “1” and “2” for the “tags” field and I send “?tags=3;4”, I want the field to have the tags “1”, “2”, “3” and “4”, not just the new “3” and “4”.

I tried prefixing the field with another semi-colon (?tags=;3;4) like suggested here: https://knowledge.hubspot.com/articles/kcs_article/contacts/how-do-i-add-values-to-a-checkbox-field-instead-of-overwriting-them-in-a-file-import

but it only works with file imports, not with the Forms API.

Is there any way to do this?

Thanks.


Unable to add a single deal property value with put
#2

Hi @jparent

There isn’t an option to append values with form submissions, so the value passed in the submission will always overwrite the existing value. We do store previous values for properties, and lists and workflows can be built to look for previous values, so even when overwritten the previous values can still be used.


#3

Thanks for your reply @dadams!

I really wanted the current value to be the correct one without having to check for previous values, so I ended up querying the contacts API to get the values for the field, and then I appended my values to the existing values before making my form post. That’s 2 API calls for a single action, but I guess it works!


#4

@jparent you have a codesnippet in which you can show how you solved this.

Regards Marc


#5

Send over multiple values delimited by a ;