- Issue created by @scott_euser
Fields like 'login' on the user entity are stored as timestamps
The SalesforceMappingFieldPluginBase::pushValue() method uses DrupalDateTime($value) passing the timestamp directly but the constructor specifically expects a string. Most dates it works for anyways, but for example "Tue Jul 15 17:52:59 GMT 4679" is returned for the timestamp equivalent of "Tue Jul 15 17:52:59 GMT 2025". Salesforce rejects the year 4679 (but if it didn't it would still be not as expected).
Hard to because not all dates fail conversion
Use DrupalDateTime::createFromTimestamp() for timestamps
N/A
N/A
N/A
Here is a sample callback for SalesforceEvents::PUSH_PARAMS subscriber to work around this for now.
public function pushParametersAlter(SalesforcePushParamsEvent $event): void {
$user = $event->getEntity();
if (!$user instanceof UserInterface) {
return;
}
$params = $event->getParams();
// For fields we know are timestamps, create the DrupalDateTime from
// timestamp specifically instead of via the constructor which expects a string.
if (
$params->hasParam('Drupal_Last_Login__c')
&& $timestamp = $user->getLastLoginTime()
) {
$date = DrupalDateTime::createFromTimestamp($timestamp);
$value = $date->format(\DateTimeInterface::ATOM);
$params->setParam('Drupal_Last_Login__c', $value);
}
}
Active
5.1
salesforce_mapping.module