I have a Date/ Time field in Snow and JC that I want to have syncronized, can you help?
To syncronize a Date/ Time field between SNOW ↔ JC, use a script connection and use this following code:
Outgoing Sync Servicenow
replica.u_datetime = entity.u_datetime
Outgoing Sync Jira Cloud
replica.customFields."datetime" = issue.customFields."datetime"
Incoming Sync Servicenow
import java.util.Date
import java.text.SimpleDateFormat
import java.util.TimeZone
import java.sql.Timestamp
def incomingDatetimeValue = replica.customFields?.datetime?.value
if (incomingDatetimeValue instanceof Timestamp) {
def date = new Date(incomingDatetimeValue.getTime())
def formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
def formattedDate = formatter.format(date)
entity.u_datetime = formattedDate
}
Incoming Sync Jira Cloud
import java.util.Date
import java.text.SimpleDateFormat
if(replica."u_datetime" != null){
def dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a")
def sourceDateTime = dateFormat.parse(replica."u_datetime")
issue.customFields."datetime".value = sourceDateTime
}
Thank you.
1 Like
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.