Originally asked by Dhiren Notani on 20 September 2022 (original question)
Comments:
Ariel Aguilar commented on 20 September 2022
HI @Dhiren what configuration is used, more details on this?
Originally asked by Dhiren Notani on 20 September 2022 (original question)
HI @Dhiren what configuration is used, more details on this?
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:
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:
def org = replica.org
issue.customFields."[OT Test] Customer Label".value += org
This is based on this documentation.
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.
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.
Hi Ola,
I think to understand what might help, may I ask to try the following on the Jira incoming:
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
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
Hi Ola, one question is this Jira Cloud or server? What Exalate version do you have?
Kind regards,
Ariel
Hi Ariel
This is Jira Cloud. The version is Exalate v. 5.3.4 (Core v. 5.3.10)
Thanks,
Ola
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
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:
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
Thanks,
Ola
Hi Ola then you can try something similar to the code suggested:
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
Hi Ariel
That has allowed the sync to complete, but given the value always reads as null it hasn’t stopped the overwriting issue.
Thanks,
Ola
Hi Ola,
By this moment, I believe it would be nice to open a support ticket because there might be something in your environment / configuration causing this problem.
Kind regards,
Ariel