In this article, we describe how to sync Date and DateTime fields in Exalate for Salesforce.
Some instances like Salesforce that rely on customKeys or internal map do not support sync of custom fields like date/DateTime from the go.
It is required to convert the value into a Long. The incoming script is different depending on the sending side.
As an example, we use Jira to Salesforce sync:
Jira Outgoing sync rules
replica.customFields."DateCf" = issue.customFields."DateCf" replica.customFields."DateTimeCf" = issue.customFields."DateTimeCf"
Salesforce Incoming sync rules
import java.text.SimpleDateFormat; import java.text.DateFormat; def dateCustomFieldValue(replicaCustomField) { def datePattern = "yyyy-MM-dd HH:mm:ss.S"; // define the desired date/time format String dateString = replicaCustomField.value; if (dateString) { dateString = dateString.replaceAll("\"","").trim(); DateFormat formatter = new SimpleDateFormat(datePattern); date = formatter.parse(dateString); return date.time; } } entity.date__c = (Long) dateCustomFieldValue(replica.customFields."DateCf") entity.datetime__c = (Long) dateCustomFieldValue(replica.customFields."DateTimeCf")
Salesforce Outgoing sync rules
replica.date__c = entity.date__c replica.datetime__c = entity.datetime__c
Jira Incoming sync rules
issue.customFields."DateCf"?.value = (Long) replica.date__c issue.customFields."DateTimeCf"?.value = (Long) replica.datetime__c
Have more questions? Ask the community