Problem/Motivation

When sending an address field to SF via an object mapping, if the field was not filled in it is transmitted as an empty array, instead of being excluded from the data packet. This results in the following error:

Cannot deserialize instance of textarea from START_ARRAY value [line:1, column:395]

Looking at the logs, this is the data that was transmitted for the address:

"Mailing_Address__Street__s":[]
"Mailing_Address__City__s":[]
"State__c":[]
"Mailing_Address__PostalCode__s":[]
"Country__c":[]

The issue here appears to be the address fields being set to empty arrays.

I'm not 100% certain if the issue is with the Webform module or Salesforce, but figured I'd start somewhere.

This is also made more complicated because it doesn't happen every time - most submissions go through as "null", which is correct.

Steps to reproduce

Set up a webform with an optional address field.
Set up an object mapping for the webform submission that maps individual address fields to individual SF fields.
Submit the webform without filling in the address field.
(exact steps TBD as not every submission has this issue)

Proposed resolution

Don't send address fields if they are empty.

Remaining tasks

Work out the best fix for the issue.
Add test coverage.

User interface changes

Empty data would not be transmitted as an empty array.

API changes

TBD

Data model changes

n/a

Comments

damienmckenna created an issue. See original summary.

damienmckenna’s picture

I did some additional tests and the following was submitted:

"Mailing_Address__Street__s":null
"Mailing_Address__City__s":null
"State__c":null
"Mailing_Address__PostalCode__s":null
"Country__c":null

It's not clear why in certain circumstances it would send NULL for the field values while in other scenarios it would send an empty array. Further testing is needed.

damienmckenna’s picture

Title: Address fields send empty array if field is empty » Sporadic issue with address fields sending empty array if field is empty, not null
Issue summary: View changes
damienmckenna’s picture

Annoyingly, I don't see any difference in the data that was logged in Webform for the two submissions :-\