Convert integers (like created/updated) to timestamps if mapped to date fields in Salesforce

Created on 18 August 2023, 10 months ago
Updated 21 May 2024, about 1 month ago

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 -

πŸ› Bug report
Status

Needs review

Version

5.0

Component

salesforce_mapping.module

Created by

πŸ‡ΊπŸ‡ΈUnited States mariacha1

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mariacha1
  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

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

    Also, see past discussion on πŸ› Mapped date fields are not properly syncing data. Closed: outdated

  • πŸ‡ΊπŸ‡ΈUnited States mariacha1

    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?

  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    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

  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
  • πŸ‡ͺπŸ‡ΈSpain keopx Basque Country

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

  • Merge request !68Resolve #3382005 "Convert integers like" β†’ (Open) created by keopx
  • Pipeline finished with Failed
    5 months ago
    Total: 182s
    #92780
  • πŸ‡ͺπŸ‡ΈSpain keopx Basque Country

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

  • Pipeline finished with Failed
    5 months ago
    Total: 1065s
    #92782
  • Pipeline finished with Failed
    5 months ago
    Total: 183s
    #92834
  • Status changed to Needs work 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    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.

  • Status changed to Needs review about 1 month ago
  • πŸ‡ΊπŸ‡¦Ukraine knyshuk.vova

    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 πŸ› Mapped date fields are not properly syncing data. Closed: outdated ,
    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.

Production build 0.69.0 2024