Confluence has been updated to ver 6.15.9. In case of any troubles, please contact infra team.

Syncing Jira Date fields to an Azure Date/Time field

 
2
1
0

Hey,


Is it possible to map a Jira date field to a date/time field in Azure DevOps? Naturally, expecting the time aspect to default to 00.00.


Cheers.

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      For any potential future readers, this was the solution Francis gave me:


      import java.text.SimpleDateFormat 
      ...
      
      def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
      def targetDate 
      if (replica.customFields."Planned Start Date"?.value){
          targetDate = sdf.format(replica.customFields."Planned Start Date".value)
          workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate
      }
      if (replica.customFields."Planned End Date"?.value){
          targetDate = sdf.format(replica.customFields."Planned End Date".value)
          workItem."Microsoft.VSTS.Scheduling.TargetDate" = targetDate
      }
        CommentAdd your comment...
      1.  
        1
        0
        -1

        Yes - it should - but the devil is in the eating of the pudding.

        What fields do you need to sync?

        1. Howard Kenny

          Ha! 


          I'm sending this in the Outgoing Sync:

          replica.customFields."Planned End Date" = issue.customFields."Planned End Date"
          replica.customFields."Planned Start Date" = issue.customFields."Planned Start Date"

          ...and this is the Incoming Sync section:

              workItem.customKeys."Microsoft.VSTS.Scheduling.StartDate" = replica.customFields."Planned Start Date".value
              workItem.customKeys."Microsoft.VSTS.Scheduling.TargetDate" = replica.customFields."Planned End Date".value

          ...but nothing populates the fields Start Date and Target Date in DevOps. 


          For info, "Microsoft.VSTS.Scheduling.StartDate" was taken from the JSON.


          I'm also struggling to sync time tracking fields. This doesn't seem to work:

          workItem.customKeys."Microsoft.VSTS.Scheduling.Effort"   = replica.originalEstimate
        2. Francis Martens (iDalko)

          I had to do some experimentation myself ...

          Found the trick - you have to use a string representation of the date

          Incoming, Tested
          import java.text.SimpleDateFormat 
          ...
          def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
          def targetDate = sdf.format(new Date())
          
          //throw new Exception("Target date = ${targetDate}")
          workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate



          Also added some more documentation on how to access the fields

          Azure DevOps: fields and entities available for synchronization

        3. Howard Kenny

          I'm having issues with that...


          'Script cannot be saved. Details: startup failed: Script297.groovy: 59: Unknown type: IMPORT at line


          I'm thinking you didn't expect me to copy and paste that whole snippet into my incoming script and instead do something special with 'import java.text.SimpleDateFormat'?

        4. Francis Martens (iDalko)

          Euh - how does the script look like when trying to save?

        5. Howard Kenny

          I tried a few ways, not fully understanding how I was supposed to insert it (and not being convinced by any of my attempts!), but...

          import java.text.SimpleDateFormat 
                  ...
                  def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
                  def targetDate = sdf.format(new Date())
                  
                  //throw new Exception("Target date = ${targetDate}")
                  workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate
                  
                  workItem.customKeys."Microsoft.VSTS.Scheduling.StartDate" = replica.customFields."Planned Start Date".value
                  workItem.customKeys."Microsoft.VSTS.Scheduling.TargetDate" = replica.customFields."Planned End Date".value

          I kept my two original lines at the end as I couldn't see how your snippet referenced the source Jira Planned Start Date fields.

        6. Francis Martens (iDalko)

          Ah - remove the elipsis (...)
          This is to denote any other code, but it is not a valid groovy construct


          Also - remove the entries with the 'customKeys' - it makes  no sense
          Of course - you will have to stringify the 'Planned Start Date' to assign it to the Start Date.


        CommentAdd your comment...