How to Sync Jira Group Assigned to Zendesk

Originally asked by David Oosting on 10 August 2021 (original question)


Attempting to pass the Group Assigned from Jira to Zendesk so that the ticket in Zendesk can get reassigned. Current code i am using is:

replica.customFields.“Group Assigned” = issue.customFields.“Group Assigned”.value

But getting this error

Unexpected error occurred. The customfield `Group Assigned`
was assigned to `value=[
{name=Customer Service, self=Products | Atlassian}

]
class=java.util.ArrayList`, but it should have been set to a custom
field object Generate an exalate support.zip file and contact support.

When i try

replica.customFields.“Group Assigned” = issue.customFields.“Group Assigned”

I get nothing sent.


Comments:

Ariel Aguilar commented on 10 August 2021

Hi David,

There are a couple of important details that you will need to share as we help you out. In Zendesk, is it a ticket field or user field? What type of field is it ? (Drop-down, Multi-select, Checkbox?) What is the incoming script for Jira? What type of field is it? (Drop-down, Multi-select (single choice), Checkbox etc…)

Kind regards,

Ariel

David Oosting commented on 10 August 2021

It is a ticket drop-down with multi-select. But looking at the Incoming and Outgoing, I am not seeing anything under customField except {}

Dave

Ariel Aguilar commented on 10 August 2021

In Zendesk, is it a drop-down? And in Jira, multi select single choice? If you are sending from Jira to Zendesk. The Jira Outgoing should be:

replica.customFields."Group Assigned" = issue.customFields."Group Assigned"

Kind regards.

Ariel

David Oosting commented on 10 August 2021

Jira Local:

  "customFields": {
      "Group Assigned": {
        "id": 10056,
        "name": "Group Assigned",
        "uid": "10056",
        "type": "UNHANDLED",
        "value": [
          {
            "name": "Customer Service",
            "self": "https://atlassian.net/rest/api/2/group?groupname=Customer+Service"
          }
        ]
      }  
Jira  Remote:
"customFields": {},  
  
Zendesk Local:
"customFields": {},  
Zendesk Remote: 
 "customFields": {
      "Group Assigned": {
        "id": 10056,
        "name": "Group Assigned",
        "uid": "10056",
        "type": "UNHANDLED",
        "value": [
          {
            "name": "Customer Service",
            "self": "https://atlassian.net/rest/api/2/group?groupname=Customer+Service"
          }
        ]
      }
David Oosting commented on 10 August 2021

So trying to get customFields.“Group Assigned”.value.name is not working.

Ariel Aguilar commented on 11 August 2021

Hi David,

Without confirming Jira Outgoing, Jira Incoming, Zendesk Outgoing, Zendesk Incoming scripts and the type of fields for both, it would be hard to continue.

Kind regards,

Ariel

David Oosting commented on 11 August 2021

Right now im just attempting to get the the if statement to work.

if(issue.customFields.“Group Assigned”.value.name == “Customer Service”) {
issue.labels += nodeHelper.getLabel(“customer_service”)
}

David Oosting commented on 11 August 2021

It does not.

No such property: name for class: com.google.gson.JsonArray

David Oosting commented on 11 August 2021

the .value equals an array

[{"name": "Customer Service","self": "https://atlassian.net/rest/api/2/group?groupname=Customer+Service"}]  
  
and dot notation is not picking name from that array.
Ariel Aguilar commented on 12 August 2021

Hi David,

If you do:

if(replica.customFields."Group Assigned".value.name.contains("Customer Service")) {
    issue.labels += nodeHelper.getLabel("customer_service")
}

Kind regards,

Ariel

David Oosting commented on 12 August 2021

No such property: name for class: com.google.gson.JsonArray

David Oosting commented on 18 August 2021

Hey Ariel, any update on this?

Ariel Aguilar commented on 20 August 2021

Hi David,

If you change it to:

if(replica.customFields."Group Assigned".value.get(0).name == "Customer Service") {
    issue.labels += nodeHelper.getLabel("customer_service")
}

Let me know if this works for you,

Kind regards,

Ariel

David Oosting commented on 20 August 2021

if(replica.customFields.“Group Assigned”.value.get(0).name == “Customer Service”) showing Not TRUE.

customFields": {
      "Group Assigned": {
        "id": 10056,
        "name": "Group Assigned",
        "uid": "10056",
        "type": "UNHANDLED",
        "value": [
          {
            "name": "Customer Service",
            "self": "https://atlassian.net/rest/api/2/group?groupname=Customer+Service"
          }
        ]
      }
Ariel Aguilar commented on 23 August 2021

Hi David,

Can you try this:

if(replica.customFields."Group Assigned".value.find()?.toString()?.name?.contains("Customer Service")){
    issue.labels += nodeHelper.getLabel("customer_service")
}

Kind regards,

Ariel

David Oosting commented on 23 August 2021

That doesnt work also. No such property: name for class: java.lang.String →

if(replica.customFields."Group Assigned".value.find()?.toString()?.name?.contains("Customer Service"))

Answer by Ariel Aguilar on 23 August 2021

Ok just it is really similar but this is it:

if(replica.customFields."Group Assigned".value.find()?.name?.toString()?.contains("Customer Service")){
    issue.labels += nodeHelper.getLabel("customer_service")
}

Comments:

David Oosting commented on 23 August 2021

Worked… thanks Ariel.

David Oosting commented on 23 August 2021

if(replica.customFields.“Group Assigned”.value.find()?.name?.toString()?.contains(“Customer Service”)){
issue.labels += nodeHelper.getLabel(“customer_service”)
}

Logic Works. Now to get the Group Assigned changed in zendesk.

Ariel Aguilar commented on 23 August 2021

You’re welcome. I have edited to make it more easy to read and understand for everybody.

Kind regards,

Ariel

Ariel Aguilar commented on 23 August 2021

Can you be more specific based on what you are looking forward to have the Group Assigned in Zendesk?

Thanks,

Ariel

David Oosting commented on 23 August 2021

Now that the Logic is sound, I now need to assign the ticket to the “Customer Support” group. Drop down from:

to:

Ariel Aguilar commented on 23 August 2021

Hi David,

You can maybe add the following:

if(replica.customFields."Group Assigned".value.find()?.name?.toString()?.contains("Customer Service")){
    issue.labels += nodeHelper.getLabel("customer_service")
	issue.assignee = nodeHelper.getUserByUsername("Customer Support")
}

Kind regards,

Ariel

David Oosting commented on 23 August 2021

Remember the Field is a multidropdown for the Assignee, so we are just assigning to the Parent Group.

Looking at the Outgoing

"assignee": {
      "key": "5d9240324258550c23a16c4c",
      "active": true,
      "email": "doosting@bet.works",
      "displayName": "David Oosting"
    }  
So this assignee looks like the requestor.
Ariel Aguilar commented on 24 August 2021

Hi David,

Sorry, I thought it was a regular assignee. I would consider instead of using Exalate for that to manually create a trigger in Zendesk with some conditions and then on actions you can specify the group.

Kind regards,

Ariel

Ariel Aguilar commented on 24 August 2021

Something like:

David Oosting commented on 24 August 2021

Im thinking that too. Easiest way around it since Multi-Dropdowns have not been the easiest to assign.

Ariel Aguilar commented on 24 August 2021

It is achievable through Exalate as well, but it will require some advanced configuration using Rest API calls. Then, on the other hand, I think setting up this Zendesk trigger it is more practical. Just let me know.

Kind regards,

Ariel