# Getting incorrect/null values while syncing labels information in a custom field from Zendesk to Jira

**URL:** <https://community.exalate.com/t/getting-incorrect-null-values-while-syncing-labels-information-in-a-custom-field-from-zendesk-to-jira/5298>\
**Category:** General Questions\
**Tags:** usecase, migrated\_question\
**Created:** [November 4, 2024, 7:56am UTC](https://community.exalate.com/t/getting-incorrect-null-values-while-syncing-labels-information-in-a-custom-field-from-zendesk-to-jira/5298 "2024-11-04T07:56:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:56am UTC](https://community.exalate.com/t/getting-incorrect-null-values-while-syncing-labels-information-in-a-custom-field-from-zendesk-to-jira/5298/1 "2024-11-04T07:56:28Z")

</div>

_Originally asked by Dhiren Notani on 20 September 2022 [(original question)](https://oldcommunity.exalate.com/questions/58494622)_

* * *

* * *

#### Comments:

> **Ariel Aguilar commented on 20 September 2022**
>
> > HI @Dhiren what configuration is used, more details on this?

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:56am UTC](https://community.exalate.com/t/getting-incorrect-null-values-while-syncing-labels-information-in-a-custom-field-from-zendesk-to-jira/5298/2 "2024-11-04T07:56:29Z")

</div>

_Answer by Ola Timpson on 21 September 2022_

In the scenario I am creating, we have a connection between Zendesk and Jira so that multiple Zendesk customer tickets link to each Jira ticket. To help our Development and Product teams understand which customers have logged an issue, we have a custom label field on Jira to list customers impacted.

Zendesk outgoing snippet:

```auto
def orgId = issue.organization_id 
if(orgId){
  def orgName = httpClient.get("/api/v2/organizations/"+(long)orgId+".json").organization.name
  replica.org = orgName.replaceAll(" ", "_")
}

```

Jira incoming snippet:

```auto
def org = replica.org
issue.customFields."[OT Test] Customer Label".value += org

```

This is based on [this documentation](https://docs.idalko.com/exalate/display/ED/How+to+synchronize+label+custom+field).

However, it doesn’t add a label to the field, it overwrites what is already there.

To try to workaround this, I tried creating a variable based on the current value of the custom field.

```auto
def currentLabel = issue.customFields."[OT Test] Customer Label".value.toString()

```

If I return this in an error or in another field it always gives null, regardless of what is in the field. So I can’t see that there is any workaround to the issue.

* * *

#### Comments:

> **Ariel Aguilar commented on 21 September 2022**
>
> > Hi Ola,
> 
> I think to understand what might help, may I ask to try the following on the Jira incoming:
> 
> ```auto
> if(issue.customFields."[OT Test] Customer Label".value == null){
> issue.customFields."[OT Test] Customer Label".value = replica.org
> } else {
> issue.customFields."[OT Test] Customer Label".value += replica.org  
> }
> 
> ```
> 
> Kind regards,
> 
> Ariel

> **Ola Timpson commented on 22 September 2022**
>
> > Hi Ariel
> 
> The suggested code has the same behaviour - replacing the value in the field not adding an additional label. Given the value always returns as being null, and even if it didn’t the += doesn’t work, I’m not surprised this was the case.
> 
> Thanks,
> 
> Ola

> **Ariel Aguilar commented on 29 September 2022**
>
> > Hi Ola, one question is this Jira Cloud or server? What Exalate version do you have?
> 
> Kind regards,
> 
> Ariel

> **Ola Timpson commented on 30 September 2022**
>
> > Hi Ariel
> 
> This is Jira Cloud. The version is Exalate v. 5.3.4 (Core v. 5.3.10)
> 
> Thanks,
> 
> Ola

> **Ariel Aguilar commented on 04 October 2022**
>
> > Hi Ola,
> 
> I reproduced this in Jira Cloud / same Exalate version and += works for me and the suggested code I sent before as well. I am wondering if you have more than 1 custom field with name [OT Test] Customer Label and Exalate is picking the first one which is not the one you see on the ticket. May ask if you can try to check what is the custom field ID and do something basic like:
> 
> `issue.customFields.``"10301"``.value += [replica.org](http://replica.org)`
> 
> `Kind regards,`
> 
> `Ariel`

> **Ola Timpson commented on 04 October 2022**
>
> > Hi Ariel
> 
> There was only 1 custom field with that name, but I tried changing the code to the field ID anyway.
> 
> Full incoming code in Jira:
> 
> ```auto
> def remoteIssueUrn = replica.customFields."Defect Reference"?.value
> if(remoteIssueUrn){
> def localIssue = httpClient.get("/rest/api/2/issue/"+remoteIssueUrn)
> if(localIssue == null) {
> throw new com.exalate.api.exception.IssueTrackerException("Issue with key "+remoteIssueUrn+" was not found")
> }
> else {
> issue.id = localIssue?.id
> issue.key = localIssue?.key
> issue.labels += nodeHelper.getLabel("zendesk")
> issue.customFields."10035".value += replica.org 
> syncHelper.syncBackAfterProcessing()
> }
> return;
> }
> 
> ```
> 
> For the first 2 issues in the sync it overwrote the label value with null[org name]. After this the sync errored with “Cannot execute null+null” when it reached a Zendesk ticket with no organisation
> 
> ![](https://dub1.discourse-cdn.com/flex018/download/attachments/58494622/image2022-10-4_9-45-15.png?version=1&modificationDate=1664873114191&api=v2)
> 
> Thanks,
> 
> Ola

> **Ariel Aguilar commented on 06 October 2022**
>
> > Hi Ola then you can try something similar to the code suggested:
> 
> ```auto
> if(issue.customFields."10035".value == null && replica.org != null){
> issue.customFields."10035".value = replica.org
> } else if(replica.org != null){
> issue.customFields."10035".value += replica.org 
> }
> 
> ```
> 
> Kind regards,
> 
> Ariel

> **Ola Timpson commented on 07 October 2022**
>
> > Hi Ariel
> 
> That has allowed the sync to complete, but given the value always reads as null it hasn’t stopped the overwriting issue.
> 
> ![](https://dub1.discourse-cdn.com/flex018/download/attachments/58494622/image2022-10-7_12-56-46.png?version=1&modificationDate=1665143805645&api=v2)
> 
> Thanks,
> 
> Ola

> **Ariel Aguilar commented on 10 October 2022**
>
> > Hi Ola,
> 
> By this moment, I believe it would be nice to open a [support](https://docs.idalko.com/exalate/x/joHk) ticket because there might be something in your environment / configuration causing this problem.
> 
> Kind regards,
> 
> Ariel
