I have a script updating a number of fields but struggling with Zendesk Assignee, what I’m doing is syncing a Jira Asset Filed and using a map in the incoming script, this is what the jira payload looks like:
},
“labels”: [],
“customKeys”: {
“assignedTeamObjectId”: “895”
This is my Zendesk incoming script, with a map for the asset ID and Zendesk Group ID
// --- Assignee Sync (Production) ---
try {
// Extract Jira Object ID
def jiraObjectId = replica.customKeys.assignedTeamObjectId?.toString()
if (!jiraObjectId && replica.customFields."Assigned Team"?.value instanceof List) {
jiraObjectId = replica.customFields."Assigned Team"?.value[0]?.objectId?.toString()
}
if (jiraObjectId) {
def groupMapping = [
"894": 25158582863772L, "895": 25158534124316L, "1104": 25158566809500L,
"899": 25158590336028L, "900": 25158575842588L, "901": 25158566891292L,
"902": 25158601422236L, "904": 25158575985820L, "905": 25158601525788L,
"906": 25158576082204L, "907": 25158567061148L, "908": 25158590623900L,
"909": 25158618218268L, "910": 25158567143452L, "911": 25158601671068L,
"912": 25158576230940L, "913": 25158567214748L, "914": 25158590809756L,
"915": 25158593104284L, "971": 25158583451932L, "917": 25158485729820L,
"918": 25158601840156L, "919": 25158618440732L, "920": 25158567389852L,
"1062": 25158590996124L, "922": 25158593264156L, "923": 25158583640476L,
"924": 25158583716508L, "925": 25158591135132L, "926": 25158618692380L,
"927": 25158583789852L, "928": 25158602217116L, "929": 25158618774556L,
"930": 25158567742748L, "931": 25158591279004L, "932": 25158593534492L,
"933": 25158583968668L, "934": 25158591345052L
]
def targetZdGroupId = groupMapping[jiraObjectId]
if (targetZdGroupId) {
def currentGroupId = ticket.groupId
if (currentGroupId != targetZdGroupId) {
ticket.groupId = targetZdGroupId
ticket.assigneeId = null // Zendesk requirement
}
}
} catch (Exception e) {
syncErrors.add("Automatic Sync Notification: Assignee Sync failed. Error: ${e.message}")
log.error("Automatic Sync Notification: Assignee Sync failed for ${replica.key ?: 'unknown'}. Error: ${e.message}", e)
}
But I just can’t seem to make it work, i.e. update the Assignee with the relevant Team