ZenDesk to Jira

Originally asked by Normann P. Nielsen on 22 December 2022 (original question)


As the Exalate support just closed my case and reffered me here… here goes:

We are trying to setup sync witha partner that uses Zendesk.

in my incoming I have:

issue.customFields.“Vendor Status”.value = replica.status
issue.customFields.“Vendor Service”.value = replica.type?.name
issue.customFields.“Vendor Priority”.value = replica.priority

All fields just being text, so I can see values.

This gives:

The last 2 I cant resolve to Jira - I need the values as strings:

def priorityMapping = [“Normal”:“Minor (P4)”, “Low”:“Minor (P4)”,“High”:“Major (P2)”,“Urgent”:“Critical (P1)”]
def remotePriorityName = replica.priority
issue.setPriority(priorityMapping[remotePriorityName] ?: remotePriorityName)

The outgoing from ZenDesk:

replica.key = issue.key
replica.assignee = issue.assignee
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.type = issue.type
replica.attachments = issue.attachments
replica.comments = issue.comments
replica.status = issue.status
replica.priority = issue.priority

Also, is this case sensitive?

issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: “Service Request”

And we have “Problem”, but the incoming is “problem”


[Failed to download attachment: attachment_58497935_mail_small.gif. Error: 401 Client Error: for url: Service Management]

[Failed to download attachment: attachment_58497935_mail_small.gif. Error: 401 Client Error: for url: Service Management]

Comments:

Serhiy Onyshchenko commented on 23 December 2022

Hello, Normann P. Nielsen
Thanks for raising this here.

All fields just being text, so I can see values.

Please, try

issue.customFields."Vendor Status".value = replica.status?.name
issue.customFields."Vendor Service".value = replica.type?.name
issue.customFields."Vendor Priority".value = replica.priority?.name


I need the values as strings:

please, give this a go:

def priorityMapping = ["Normal":"Minor (P4)", "Low":"Minor (P4)","High":"Major (P2)","Urgent":"Critical (P1)"]
def remotePriorityName = replica.priority?.name
issue.setPriority(priorityMapping[remotePriorityName] ?: remotePriorityName)

Also, is this case sensitive?

Yes, unfortunately, it is, so you could do a mapping:

def issueTypeMapping = ["problem":"Problem"]def mappedIssueType = issueTypeMapping[replica.type?.name] ?: replica.type?.nameissue.typeName = nodeHelper.getIssueType(mappedIssueType, issue.projectKey)?.name ?: "Service Request"

Please, let me know, how it goes
Regards, Serhiy.

Answer by Normann P. Nielsen on 28 December 2022

hi Serhiy,

Tanks - this was perfect:

issue.customFields."Vendor Status".value = replica.status?.name
issue.customFields."Vendor Service".value = replica.type?.name
issue.customFields."Vendor Priority".value = replica.priority?.name

for the mappings, I use switch to make the code simpler for all to read:

if(firstSync){
   issue.projectKey   = "TEST" 
   // Set type name from source issue, if not found set a default
   switch(replica.type?.name)
   {
       case "incident":
            issue.typeName = "Incident"
            break;
        case "problem":
            issue.typeName = "Problem"
            break;
        default:
            issue.typeName = "Service Request"
    }
}
issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue, replica)
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
issue.labels       = replica.labels
issue.customFields."Vendor Status".value = replica.status?.name
issue.customFields."Vendor Service".value = replica.type?.name
issue.customFields."Vendor Priority".value = replica.priority?.name

switch(replica.priority?.name)
{
   case "urgent":
        priority = "Critical (P1)"
        break;
    case "high":
        priority ="Major (P2)"
        break;
    default:
        priority ="Minor (P4)"
}

issue.priority = nodeHelper.getPriority(priority, issue)



This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.