We have a form where the date of birth is optional. In 7.x-1.3, when a date is not entered, the salesforce_webforms date filters return '0000-00-00', and what's saved in the Salesforce contact for birth date is today's date. In 7.x-dev with #2797113: Date of birth conversion goes wrong, not entering a date results in Salesforce refusing to save the record because salesforce_webforms_date[time]_filter()
returns gibberish when given an empty string.
Proposed resolution
In salesforce_webforms_date[time]_filter()
check if the string was successfully parsed into a date and return NULL if it was not. Salesforce seems to be satisfied with NULL in my tests.
Comments
Comment #2
ChaseOnTheWebPatch attached
Comment #3
dbcollies CreditAttribution: dbcollies commentedThanks for the patch. I've got a lot on my plate right now, but I'll review this as soon as I can.
Comment #4
dbcollies CreditAttribution: dbcollies commentedThe basics of this patch look good, but I think I want to expand on it a bit. Rather than silently converting any bad string into a NULL, I think it would be better to do the following:
Of course the current API doesn't allow filters to raise error conditions, so that may need to be visited. I'll look into it some more.
Comment #5
dbcollies CreditAttribution: dbcollies commentedI've put together a new patch which hopefully addresses your concerns, as well as the changes I talked about above.
Please give it a try and let me know if you uncover any issues.
Comment #6
dbcollies CreditAttribution: dbcollies commentedI've reworked my patch slightly. I moved where the processing of suppressing the save and generating messages to AFTER the submission hooks have been called, in case a hook handler also wants to make use of this new facility.
Comment #7
chill5-0 CreditAttribution: chill5-0 commentedI'm not sure if this is related - I have a date field in which the "day" dropdown is hidden (webform option). Webform says the default value that's saved is "1", but when I try submitting the webform, I receive an error "Error creating Salesforce object: [name of my field]: invalid date: Sun Nov 30 00:00:00 GMT 2". Also, the date I am submitting is Jan 2018, but the error msg is for Sun Nov 30. I have 7.x-1.x-dev installed and tried applying patch #6, but I think it's already applied in this version of the module. Not sure if this adds any insight, but thank you for creating this module - it has been very helpful in pushing data to our SF instance.