• Resolved adamsmm

    (@adamsmm)


    Hello! This plugin is incredibly useful, however I’ve run into one issue that I can’t seem to resolve. I’m pulling data from Salesforce into WordPress, specifically the Events Calendar plugin, and the date is not being matched. Whenever it pulls/syncs, it populates the date field with the current date, likely because the format is invalid and it defaults to today.

    Is there a way to get that object field to match the proper date & time format? I saw there was a date format feature posted in Github but it doesn’t look like that was ever merged.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    Can you speak to how the data in Salesforce works? What object are you using in Salesforce to store the events? The plugin expects Salesforce to send dates with 'Y-m-d\TH:i:s\Z' as their format; do you know if it’s doing that?

    If it is, the plugin then tries to convert a date into 'Y-m-d H:i:s'. At least in the past, that was what The Events Calendar used, although it has been some time since I’ve tested this and they may have changed it since then. Do you know if they have, and if so, what they’re using now?

    If either of these has changed, I’d be happy to update the plugin to reflect that.

    If they haven’t, it’s true that the plugin’s interface does not have the ability to change date formats. You can do it with the object_sync_for_salesforce_pull_params_modify hook. There’s some documentation on that, although it does not cover date formats. But ideally, it would be better to fix, if something has changed between The Events Calendar and Salesforce.

    Thread Starter adamsmm

    (@adamsmm)

    Thanks for the quick response! The field in the Salesforce object is set to the data type Date/Time and I can confirm it’s outputting in a proper format (sent it to the excerpt field, it displayed 2022-06-08 12:00:00).

    As for the Events Calendar side, it looks like by default it should be following the same rules. I even pasted that same date/time output in the Start field and it formatted correctly after saving, though I don’t know if it’s just automatically fixing the format. The plugin has two different meta fields for start & end dates: _EventStartDate and _EventStartDateUTC. I’ve tried mapping to both and it’s still not setting the date, so not sure what’s missing here.

    I looked through the dev docs but didn’t see anything about the format in the field itself, just how options on its front-end display.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    I think I’ve found something this plugin has used for some time, but on creating a new event it seems like it doesn’t work anymore. It’s not a hard fix; if you’d be willing to test it I’d appreciate it.

    In the plugin file classes/class-object-sync-sf-wordpress.php, on line 2365, currently it reads like this:

    $dates[ 'Event' . $date_type . 'Date' ] = $timestamp;

    If you can change it to instead read like this:

    $dates[ 'Event' . $date_type . 'Date' ] = gmdate( Tribe__Date_Utils::DBDATEFORMAT, $timestamp );

    It’s not clear to me when they changed this so I may not be able to target the correct version for backward-compatibility, but I think that’s probably acceptable if it works for their current version.

    Thread Starter adamsmm

    (@adamsmm)

    That worked! On my version of the plugin (the latest from here, not github), that was on line 2636.

    This has saved me from many more headaches. Thank you!

    One other quick (unrelated) question: I’m getting a few invalid post ID errors, likely because I deleted some entries in WordPress. Now those events from Salesforce can’t be pulled into WP. I’ve set the prematch to be post_title and turned on the “always delete object maps” option but that hasn’t changed the result. Is there an additional setting or parameter I’m missing?

    Thread Starter adamsmm

    (@adamsmm)

    Nevermind, I figured that part out. Thanks again for your help with the event date!

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    Great. Also, I will get this fix out in the plugin with a 2.2.4 release within the next day or two.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Matching date & time format’ is closed to new replies.