Problem/Motivation

Sometimes you want to take something that's saved in Drupal as an integer but that really represents a timestamp, and push it up to a date/time field in Salesforce.

Steps to reproduce

Map your node's created or changed field to a Date field in Salesforce. See an error.

Proposed resolution

Add a integer->date converter to modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php when in integer is mapped to a date. Add it on both pushValue and pullValue

Remaining tasks

Write the patch

User interface changes

- none -

API changes

- none -

Data model changes

- none -

Issue fork salesforce-3382005

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mariacha1 created an issue. See original summary.

aaronbauman’s picture

Category: Feature request » Bug report
Related issues: +#3122412: Mapped date fields are not properly syncing data.

\Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase::pushValue is supposed to handle this, so let's consider this a bug.

Also, see past discussion on #3122412: Mapped date fields are not properly syncing data.

mariacha1’s picture

Shoot, I didn't find that open issue! That's the same issue as this one in my opinion, although the patches there only deal with pushing. @AaronBauman I'm fine with closing this as a duplicate and moving patching over to there, if it's ok to also work on pulls in that issue too?

aaronbauman’s picture

i think it's fine to keep both issues open, as that one has a lot of baggage already and is tagged on 4.x

keopx made their first commit to this issue’s fork.

keopx’s picture

Status: Active » Needs review
Issue tags: +salesforce_pull, +salesforce_mapping

I created the patch to transform SF date to the timestamp for created/changed value.

keopx changed the visibility of the branch 3382005-convert-integers-like to hidden.

aaronbauman’s picture

Status: Needs review » Needs work

Looping back around on this one.
AFAIK this MR addresses an impossible scenario - a "datetime" field from salesforce whose data is getting pulled as an integer.

Salesforce stores datetime values as strings in iso8601 format, which is what the current \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase::pullValue method checks for.

Maybe what we want is for the module to be aware of the Drupal field type and cast an integer value from Salesforce accordingly. That's a much bigger can of worms (ie. what other mis-matched field types do we want to support?), and not addressed by this MR as best I can tell.

knyshuk.vova’s picture

Status: Needs work » Needs review
Issue tags: +salesforce_push
StatusFileSize
new3.09 KB

The attached patch adds timestamp value push support by converting timestamp into supported by Salesforce format.

The code originally from the last patch in old discussion branch https://www.drupal.org/project/salesforce/issues/3122412#comment-14116705 ,
additionally fixed bugs
- 'date' salesforce type converting
- possibly missing requested drupal field definition (due to 'drupal_field_value' may have not a drupal field name value)

Tests coverage still needed, not included in this patch, but some tests (not all) exists in old discussion branch.

nnevill’s picture

Works with 5.1.1.

Thanks!

scott_euser’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed yeah, we have been using this patch successfully for some time and it resolves the error when mapping to a date field. Thank you!

aaronbauman’s picture

Version: 5.0.x-dev » 5.1.x-dev
Status: Reviewed & tested by the community » Needs work

Patch from #11 appears to be a different approach from the MR.
Please reconcile these features and update the MR.

scott_euser changed the visibility of the branch salesforce-3382005 to hidden.

scott_euser changed the visibility of the branch 5.0.x to hidden.

scott_euser changed the visibility of the branch 5.1.x to hidden.

scott_euser’s picture

Status: Needs work » Reviewed & tested by the community

Patch from #11 definitely the correct one that solved the issue. Updated issue fork and MRs, cleaned up old MRs. No actual code change from me here, directly applied patch so going back to RTBC rather than NR. Thanks!

scott_euser’s picture

Updated test coverage to expect iso 8601 date format per SF docs: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightni...

liam morland made their first commit to this issue’s fork.