Hi
I updated Outgoing sync:
// Set Zendesk_follow to a comma-separated list of follower emails, only if the field exists
if (issue.customFields.containsKey(âZendesk_followâ)) {
*if (replica.followers instanceof List) {*
*issue.customFields.'Zendesk_follow'.value = replica.followers.collect { it?.email ?: '' }.findAll { it }.join(', ')*
*} else {*
*issue.customFields.'Zendesk_follow'.value = ''*
*}*
}
// Set Zendesk_cc to a comma-separated list of CC emails, only if the field exists
if (issue.customFields.containsKey(âZendesk_ccâ)) {
*if (replica.ccs instanceof List) {*
*issue.customFields.'Zendesk_cc'.value = replica.ccs.collect { it?.email ?: '' }.findAll { it }.join(', ')*
*} else {*
*issue.customFields.'Zendesk_cc'.value = ''*
*}*
}
// Map other fields as per current configuration
replica.summary = issue.summary
replica.comments = issue.comments
replica.attachments = issue.attachments
replica.type = issue.type
replica.status = issue.status
replica.priority = issue.priority
replica.assignee = issue.assignee
replica.reporter = issue.reporter
replica.key = issue.key
replica.labels = issue.labels
replica.description = issue.description
replica.zendeskCreated = issue.created
And incoming sync:
// Helper function to safely set a custom field value if the field exists
void setCustomFieldValue(issue, fieldName, value) {
*if (issue.customFields\[fieldName\] != null) {*
*issue.customFields\[fieldName\].value = value*
*}*
}
if (firstSync) {
*issue.projectKey = "ZEN"*
}
def defaultUser = nodeHelper.getUserByEmail(âjira-placeholder@lhv.eeâ)
issue.reporter = nodeHelper.getUserByEmail(replica.requester?.email) ?: defaultUser
issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
// Set custom field Zendesk_follow to comma-separated emails from followers, or empty string
// if (replica.followers instanceof List) {
// setCustomFieldValue(issue, âZendesk_followâ, replica.followers.collect { it?.email }.findAll { it }.join(â,â))
// } else {
// setCustomFieldValue(issue, âZendesk_followâ, ââ)
// }
// Set summary: use replica.summary if not empty/null, otherwise use replica.key if not empty/null, otherwise default
if (replica.summary?.trim()) {
*// Replace all newline characters in the summary with a space*
*issue.summary = replica.summary.replaceAll(/\[\\r\\n\]+/, ' ')*
} else if (replica.key?.trim()) {
*issue.summary = replica.key*
} else {
*issue.summary = 'No summary provided'*
}
issue.description = replica.description
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.labels = replica.labels
issue.type = nodeHelper.getIssueType(replica.type?.name, issue.projectKey) ?: nodeHelper.getIssueType(âZendeskâ, issue.projectKey)
def priorityMap = [
*"urgent": "Highest",*
*"high" : "High",*
*"normal": "Medium",*
*"low" : "Low"*
]
def priorityName = priorityMap[replica.priority?.name?.toLowerCase()] ?: âMediumâ
issue.priority = nodeHelper.getPriority(priorityName)
// FIX: Improve status mapping to be case-insensitive and include missing statuses
def statusMap = [
*"new" : "Open",*
*"open" : "Open", // Added mapping for "open"*
*"pending" : "In Progress",*
*"waiting" : "In Progress",*
*"solved" : "Closed",*
*"rejected" : "Closed",*
*"done" : "Closed"*
]
def remoteStatusName = replica.status?.name?.toLowerCase()
// Only update status if a valid mapping exists to avoid accidental changes
if (statusMap.containsKey(remoteStatusName)) {
*issue.setStatus(statusMap\[remoteStatusName\])*
}
// Set custom fields for created date and key
issue.customFields.âZendesk_createddateâ.value = replica.zendeskCreated
setCustomFieldValue(issue, âZendesk_keyâ, replica.key)
setCustomFieldValue(issue, âZendesk_Assigneeâ, replica.assignee?.email)
setCustomFieldValue(issue, âZendesk_Reporterâ, replica.reporter?.email)
setCustomFieldValue(issue, âZendesk_CC_Emailsâ, replica.cc_emails?.join(", "))
setCustomFieldValue(issue, âZendesk_followâ, replica.followers?.join(", "))
Seems to be that right now we donât get over Zendesk_createddate, Zendesk_CC_Emails and Zendesk_follow.
Maybe there is still some issue what i did wrong in configuration?
with best
Urmo