1
0
-1

I know this has been asked a few times, but none of the documentation seems to help me.

https://docs.exalate.com/docs/how-to-sync-datedatetime-custom-fields-in-jira-cloud


Use Case:

I want to sync issue start date from one Jira cloud instance to another Jira cloud instance

I already do this with Due Date


Outbound sync from instance A:

   replica.due            = issue.due
   replica.start          = issue.customFields."14107"


I did a quick debug.error(replica.start.value) output check on instance A and the Start Date is displayed as Mon May 08 00:00:00 UTC 2023


Inbound sync to instance B:

	issue.customFields."10015".value  = replica.start.value
	issue.due          = replica.due


I did a quick debug.error(replica.start.value) output check on instance B and the Start Date is displayed as 1.683504E12


It is not updating the field on instance B at all.  Leaving me to wonder why it shows a weird number value on instance B?


  • On both instances the Start Date is a locked field under Custom Fields
  • On both instances the Start Date is a Date Picker field


What am I doing wrong?


Ps. The Due Date sync seems to work differently as per documentation found and is working correctly
https://docs.exalate.com/docs/how-to-synchronize-a-due-date-field-in-jira-cloud

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Charlie Schonken


      It's not updating because the date time field does not recognize the format that's been sent over (1.683504E12).

      To do this you need to apply a few changes in your script.


      If you want to sync the “Start date” field you can use the Timestamp method.
      The “Start date” is indeed a custom field in Jira Cloud, but you can access it in Exalate by doing: 

      Outgoing Sync
      replica."Start date" = issue."Start date"

      If you use this format you don't need to use the “.value” later on.

      Now in the Incoming script you need 2 things

      1. Date date = new Date(long date)
      2. new Timestamp(long time), note that you'll need to import “java.sql.Timestamp”.
      Incoming Sync
      import java.sql.Timestamp
      
      Date date = new Date((long)replica."Start date")
      issue."Start date" = new Timestamp(date.time)

      From the Start date custom field you'll get a double in unixtime (replica."Start date" = 1.683504E12) or (replica."Start date" = 168350400000).
      This format needs to be converted, to do this use the Date object. The Date object expects a long, so we cast this by putting (long) before our variable. 


      We use Timestamp to convert it to a date time object in Jira.
      With the imported “java.sql.Timestamp” library you can call a new timestamp by new Timestamp(long date).

      Set the issue “Start date” = new Timestamp(date.time).

      Now you should see your Start date in your issues.

      I hope this answers your question? 

      Thanks,

      Christophe


      1. Charlie Schonken

        Worked like a charm - much appreciated

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi!

      In our Exalate sync this works too:

      • outgoing: replica.customFields."Start date" = issue.customFields."Start date"
      • incoming: issue.customFields."Start date" = replica.customFields."Start date"


      Best regards,

      Richard

        CommentAdd your comment...