2
1
0

Hi I am trying to sync a hidden zendesk field "Submitter" it is a system field only accessible via the API but represents who actually created the ticket (see here for more details: https://developer.zendesk.com/rest_api/docs/support/tickets) to the reporter in JIRA. However, it looks like that field is not accessible via exalate.

The "Submitter" also creates the first comment on the zendesk ticket so I was trying to use that to set reporter by getting the author of the first comment but was struggling with that as well and it was not working:

Zendesk Outgoing:

replica.comments = issue.comments


JIRA Incoming:

if(firstSync){
issue.projectKey = "NOC"
// Set type name from source issue, if not found set a default
issue.typeName = "Incident"
def reporter = null
issue.comments = commentHelper.mergeComments(issue, replica)

{ reporter = it.author?.email it.executor = nodeHelper.getUserByEmail(it.author?.email) }

if (reporter != null)

{ issue.reporter = userHelper.getByEmail(reporter) }

}
    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Francis Martens (Exalate) thank you for all the help, I wanted to post the final solution that I got to work:


      Zendesk Outgoing:

      // Submitter of Ticket (ie Reporter)
      def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
      Long submitterId = ticketDetails["ticket"]["submitter_id"]
      def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
      replica.customKeys."Reporter Email" = userDetails.user.email


      JIRA Incoming:

      def reporterEmail = replica.customKeys."Reporter Email"
      if (reporterEmail) {
          issue.reporter = userHelper.getByEmail(reporterEmail) ?: defaultUser
      } 
      CommentAdd your comment...
    2.  
      1
      0
      -1

      Aparently an oversight in the Exalate API


      A workaround can be based by using the httpclient


      def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
      Long submitterId = ticketDetails["ticket"]["submitter_id"]
      
      def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
      throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")


      Give it a try.  I will raise some requests on our backlog...

      1. Spencer Johnson

        Francis Martens (Exalate)  where should I put that? The error thrown from the exception displayed the userDetails properly but I am not sure how to send that to JIRA


        This is what I tried but am getting an error on the zendesk side (Details: Cannot cast object):


        Zendesk Outgoing:

        // Submitter of Ticket (ie Reporter)
        def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
        Long submitterId = ticketDetails["ticket"]["submitter_id"]
        
        def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
        //throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")
        replica.reporter = userDetails


        JIRA Incoming:

        if (replica.reporter != null){
            issue.reporter = userHelper.getByEmail(replica.reporter?.email)
        }


        I also tried this and didn't get an error but the value isn't there on the JIRA side:

        Zendesk Outgoing:

        // Submitter of Ticket (ie Reporter)
        def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
        Long submitterId = ticketDetails["ticket"]["submitter_id"]
        
        def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
        //throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")
        replica.customFields."Reporter Email" = userDetails.email // this is not an actual custom field name 


        JIRA Incoming:

        def reporterEmail = replica.customFields."Reporter Email"?.value
        if (replica.customFields."Reporter Email"?.value != null){
            issue.reporter = userHelper.getByEmail(replica.customFields."Reporter Email".value)
        }

        I also tried to throw an exception with the value of reporterEmail on the JIRA side but it came back as null

      2. Francis Martens (Exalate)

        Instead of 


        replica.customFields."Reporter Email" = userDetails.email // this is not an actual custom field name 
        
        
        

        You can use customKeys


        Outgoing Zendesk
        replica.customKeys."Reporter Email" = userDetails.email 


        And then on the receiving side


        if (replica.customKeys."Reporter Email") {
           issue.reporter = userHelper.getByEmail(replica.customKeys."Reporter Email")
        }



      3. Spencer Johnson

        Thanks for the help Francis Martens (Exalate) I had to make a small tweak which I posted as answer but it is working now!

      CommentAdd your comment...