1
0
-1

I need to get the the Zendesk ticket created date and populate to a custom date field in Jira On Prem. 

However the issue.created value does not seem to work in Zendesk. The Exalate doco (How to Sync CreatedDate Field? | Exalate Documentation) doesn't show Zendesk in the list of system labels at the top of the screen. But I tried it anyway.


When I put this in the Zendesk outgoing script:

replica.created = issue.created
debug.error("replica.created = " + replica.created)


I get this error message:

Sync rules error
replica.created = null


Am I doing something wrong? Or is there another way/command to get the date a Zendesk ticket is created?

thanks, Sandra

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Sandra Campbell,


      Using the following in the Zendesk outgoing script should suffice:

      def res = httpClient.get("/api/v2/tickets/${issue.key}.json")
      def created_at = res.ticket.created_at 
      debug.error("${created_at}")

      but you need to be careful about the format you receive it on the destination end. You might need to manipulate it a little (not sure as I have not tested it end to end). 


      Hope it helps. 


      Thanks

      Majid


      1. Sandra Campbell

        hi Syed Majid Hassan

        that got me the required date info, and yes it does need some manipulation to get it into the right format,

        appreciate your help

        thanks, 

        Sandra


      2. Sandra Campbell

        This is what ended up working ...


        Zendesk outgoing script 

        def res = httpClient.get("/api/v2/tickets/${issue.key}.json")
        def inputDate = res.ticket.created_at
        replica."Date created" = inputDate


        Jira On Prem incoming script 

        import java.time.Instant
        import java.time.LocalDateTime
        import java.time.ZoneOffset
        import java.time.format.DateTimeFormatter
        
        def inputDate = replica."Date created"
        def formatter = DateTimeFormatter.ISO_INSTANT
        def instant = Instant.from(formatter.parse(inputDate))
        def epochTimestamp = instant.toEpochMilli()
        issue.customFields."ZD Created date".value = epochTimestamp
      3. Syed Majid Hassan

        Awesome! Ye I feared that date formatting thing. 

        Glad to see it work. 

        Thanks for sharing


      CommentAdd your comment...