nateleavitt / infusionsoft

Ruby Gem for the Infusionsoft API
MIT License
58 stars 63 forks source link

Fails to update datetime field when using ContactService.addWithDupCheck #74

Closed spence-man closed 2 years ago

spence-man commented 4 years ago

We have an issue when we try to update a contact's custom datetime field when using ContactService.addWithDupCheck.

I opened a ticket with Infusionsoft as I believe it may be an issue on their end, yet I also just wanted to double check this scenario here.

ContactService.addWithDupCheck works on first attempt to create a new contact record. Yet, on a second call or more, with an existing contact, the custom datetime fields fail to update. Our normal use case is we have a variety of custom fields (first name, last name, datetime, etc) that get updated in a single bulk update. All fields will update properly except the datetime fields.

A workaround I figured out is to do a separate update call for that contact record using ContactService.update.

Another issue I encountered is being able to clear a field that is no longer needed. It seems the Infusionsoft API rejects our data if certain keys are present, but have no value. Yet, I found that using the string zero "0" allows us to clear out the field.

For example, currently we have two custom datetimes (ex: day 1, day 2) for each contact record. For one scenario, we create the record and set the two custom datetimes which work. Then, on an update call, if we need to update day 1 datetime and clear/reset day 2, there was an issue using an empty string "" and nil as a value. Setting day 2 to "0" seemed to work and the reset the field to default (and day 1 would update as well).

Is there a known issue or note using addWithDupCheck in a bulk update? Is using string zero "0" a valid way of resetting a value for a field?

nateleavitt commented 2 years ago

Hi @spence-man, sorry this is late, but I will respond anyway. The addWithDupCheck in the infusionsoft/keap api is to add a contact but check to see if an existing contact exists before doing so. If it finds a duplicate contact it should update the fields. It might only update certain fields.. not exactly sure.

Clearing out a field might only be accomplished the way you are doing it. Another suggestion would be to update strings using an empty string like " ". But not sure that would work either. Let me know if you have any questions.