Problems syncing 'Target Date' field from Azure DevOps to Jira Cloud

Originally asked by Chris Rogers on 13 August 2022 (original question)


Hello,

I am trying to set up a one-way sync between Azure DevOps (source) and Jira Cloud (destination). I have the sync working with the exception of the Target Date field.

The remote payload shows the date as follows:

customKeys": {
“Target Date”: “2022-01-31T00:00:00Z”
}

I’ve followed another users example here: Sync Due Date from Azure DevOps to JIRA cloud (old community)

But keep getting an error when trying to format the data as a date. When I try to put that data into a text field for troubleshooting, I get a weird field value ([B@2abd3e2c). I feel like I’m close but missing something obvious, has anyone else had issues with this and if so, how did you resolve them?

Thanks!


Comments:

Jose Pablo Alpizar Hidalgo commented on 15 August 2022

Hello Chris Rogers

Just to narrow down the case, would you please verify that the definition is set well set on the Azure DO project by following the next article’s steps:
https://keithbabinec.com/2021/02/28/how-to-visually-highlight-overdue-work-items-on-an-azure-devops-sprint-board/
Would you please also share with us what is your connection type is and the error message you get?

Answer by Chris Rogers on 16 August 2022

Hi Jose,

Confirmed. The Target Date field is set up as a Date/Time field in ADO. I first tried to set this up as a visual connection with a small script to copy the value over but that didn’t work so I’ve setup a scripted connection.

The error I get is: Cannot format given object as a Date.


Comments:

Ariel Aguilar commented on 16 August 2022

Hi Chris,

I guess you are trying to sync to a date and time picker custom field in Jira Cloud?

Kind regards,

Ariel

Chris Rogers commented on 17 August 2022

Hi Ariel,

I am trying to take a work item in Azure DevOps and sync several fields into an issue in Jira Cloud. I’ve got the rest of the sync working, but the date/time picker from Azure DevOps (named Target Date) syncing into Jira Cloud (also named Target Date) is proving to be a challenge.

Ariel Aguilar commented on 17 August 2022

Try this:

issue.customFields."Target Date".value =  new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(replica.customKeys."Target Date".replace("Z","CST"))

When parsing the text the Z it is expecting a value instead of variable, so to get it sorted we are replacing the Z by an abbreviation of the system timezone so make sure the value gets properly added. Otherwise, so might get the value added with the default UTC offset timezone provided by the API.

Kind regards,

Ariel

Chris Rogers commented on 19 August 2022

Hi Ariel,

Thanks! This was what I was looking for and worked wonderfully; the time zones don’t match between the instances but we can live with that for now.

Thanks so much!