2 answers
- 210
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 }
- Francis Martens (Exalate)
Awesome
Add your comment... - 10-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...- 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
- Francis Martens (Exalate)
Instead of
replica.customFields."Reporter Email" = userDetails.email // this is not an actual custom field name
You can use customKeys
Outgoing Zendeskreplica.customKeys."Reporter Email" = userDetails.email
And then on the receiving side
if (replica.customKeys."Reporter Email") { issue.reporter = userHelper.getByEmail(replica.customKeys."Reporter Email") }
- 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!
Add your comment...
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:
JIRA Incoming: