Unable to sync a custom user field from Zendesk to Jira

ZD Outgoing


import groovy.json.JsonOutput
replica.customFields."Jira-Assignee" = issue.customFields."Jira-Assignee"
if(issue.customFields."Jira-Assignee"){
if(issue.customFields."Jira-Assignee".value){
def fields = response.ticket.custom_fields
def jira_assignee_id = fields.find { it.id == 39307137779217 }?.value
def jira_assignee_data = httpClient.get("/api/v2/users/${jira_assignee_id}")
def AssigneeName = jira_assignee_data.user.name
replica."Jira Assignee" = AssigneeName
}}
//debug.error("${fields}")

Jira Incoming

//Jira Incoming sync
if(!replica."Jira Assignee")
{
  replica."Jira Assignee" = "Assignee N/A"
}
if(!replica."Jira Reporter")
{
  replica."Jira Reporter" = "Reporter N/A"
}
if(replica.assignee)
{
issue.customFields."Exalate: Jira Ticket Details".value = "Jira ID : " + replica.key + "\n" + "Jira Summary : " + replica.summary + "\n" + "Jira Reporter : " + replica.reporter.displayName + "\n" + "Jira Assignee : " + replica.assignee.displayName + "\n" + "Jira Status : "+replica.status.name + "\n" + "Jira Assignee :" + replica."Jira Assignee"  
}
else{
 issue.customFields."Exalate: Jira Ticket Details".value = "Jira ID : " + replica.key + "\n" + "Jira Summary : " + replica.summary + "\n" + "Jira Reporter : " + replica.reporter.displayName + "\n" + "Jira Assignee : " + "Unassigned" + "\n" + "Jira Status : "+replica.status.name + "\n" + "Jira Assignee :" + replica."Jira Assignee"  
}

Syncing custom user fields between Zendesk and Jira can be tricky, especially when dealing with user objects and custom fields. Based on the Exalate documentation, here are some key points and suggestions to help you resolve your issue:

  1. Syncing User Fields from Zendesk
    To sync user fields like assignee, reporter, or creator from Zendesk, you should send the user object directly in your Zendesk Outgoing sync script:

    replica.assignee = ticket.assignee
    replica.reporter = ticket.reporter
    replica.creator = ticket.creator
    

    For custom user fields, you can assign the custom field value (if it’s a user object) to a replica property.

  2. Handling Custom User Fields
    If your custom field in Zendesk is a user field, you should pass the user object (not just the name or ID) to the replica. For example:

    replica.customFields."Jira-Assignee" = ticket.customFields."Jira-Assignee"
    

    If you need to fetch additional user details (like name) using the user ID, ensure the API call is correct and the result is properly assigned.

  3. Jira Incoming Sync: Setting the User Field
    On the Jira side, to set a custom user field, use the appropriate nodeHelper method. For example, if your custom field is of type “user”, you can do:

    issue.customFields."Jira-Assignee"?.value = nodeHelper.getUserByEmail(replica.customFields."Jira-Assignee"?.value?.email)
    

    If the email is not available, you may need to use another identifier or a mapping.

  4. Reference Documentation

Summary:

  • Make sure you are passing the user object (not just the name or ID) in the replica.
  • On the Jira side, use nodeHelper.getUserByEmail or similar methods to set the user field.
  • If your custom field is not of type “user” in Jira, you may need to adjust your approach.

If you follow the patterns in the documentation above, you should be able to sync your custom user field successfully. If you still encounter issues, double-check the field types and the data being passed in the replica.

Hi,

The issue here is the field id itself, the scientific notation of the field needs to be used. You can remove the debug.error() to find the scientific notation of the field.

Once you replace this part, it should work.

Thanks, Dhiren