Unable to set Jira custom field

I have a sync that starts on Zendesk and creates a Jira issue.

I have an error on the custom Jira field named “Region”.

The field is defined, in Jira, as a single-value list, but the input helper is set to multi value helper.

If I create such a ticket directly in Jira, and I look at its structure with Jira APIs, I see this:

...
    "customfield_12060": {
      "self": "https://<---->.atlassian.net/rest/api/2/customFieldOption/13236",
      "value": "Italy",
      "id": "13236"
    },
...

This is the error:

Unexpected error occurred. The customfield `Region` was assigned to `value=BasicHubOption{id=‘13236’, value=Italy, sequence=‘null’, disabled=‘null’} class=com.exalate.basic.domain.hubobject.v1.BasicHubOption`, but it should have been set to a custom field object

I tried various methods, like:

issue.customFields.”Region”.value = “Italy”
issue.customFields.”Region”.value = [value: “Italy”]
issue.customFields.”Region”.value = {value: “Italy”}
issue.customFields.”Region”.value = [{value: “Italy”}]
issue.customFields.”Region”.value = [id: “13236”]
issue.customFields.”Region”.value = {id: “13236”}
issue.customFields.”Region”.value = [{id: “13236”}]
issue.customFields.”10260”.value = “Italy”
issue.customFields.”10260”.value = [value: “Italy”]
issue.customFields.”10260”.value = {value: “Italy”}
issue.customFields.”10260”.value = [{value: “Italy”}]
issue.customFields.”10260”.value = [id: “13236”]
issue.customFields.”10260”.value = {id: “13236”}
issue.customFields.”10260”.value = [{id: “13236”}]

The error never changes.

At last, for desperation, I removed completely the assignment of the custom field.

My Jira-side incoming script now looks really simple:

if (firstSync) {
    issue.projectKey  = "MYKEY"
}

issue.type = nodeHelper.getIssueType("Service Request", issue.projectKey)
issue.summary      = replica.summary
issue.description  = replica.description
issue.labels       = replica.labels
issue.comments     = commentHelper.mergeComments(issue, replica)
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)

Just as simple as that –> same error.

Can someone help me understand/fix?

Thanks

It looks like you’re running into a common issue when setting a Jira custom field of the “Select List” type (single or multi-select) via Exalate’s scripting. The error message suggests that the value you’re assigning isn’t matching what Jira expects for that custom field.

For select list fields, Jira expects an object with an id or value, not just a plain string. Here’s how you can set it correctly in Script mode:

// Replace "Region" with the actual custom field name or ID if needed
issue.customFields."Region" = new com.exalate.basic.domain.hubobject.v1.BasicHubOption("Italy")

Or, if you know the option ID (which is more reliable):

issue.customFields."Region" = new com.exalate.basic.domain.hubobject.v1.BasicHubOption(id: "13236", value: "Italy")

A few tips:

  • Make sure the value (“Italy”) exactly matches the option in Jira, or use the option’s ID for best results.
  • Don’t assign to .value directly; assign the BasicHubOption object to the custom field itself.

You can find more details and examples in the Exalate documentation here:
https://docs.exalate.com/docs/how-to-set-select-list-custom-fields-in-jira

This should resolve the error and set your “Region” field as expected.

The solution provided does not work.

The link provided is not existent.

Hi @Aldo_Ercolani,

I hope you are doing well.

If you want to set the value of your select list custom field, you can use the following script:

// Single select list
issue.customFields."Region".value = "Italy"

// Multi Select list
// Only one value
issue.customFields."Region".value = "Italy"
// Multiple values
issue.customFields."Region".value = ["Italy", "Other Value"]

To make it dynamic you can use the following:

issue.customFields."Region".value = replica.customFields."CF Name"?.value?.value

I saw in your error that you are assigning a custom field object to the value of the field.

value=BasicHubOption{id=‘13236’, value=Italy, sequence=‘null’, disabled=‘null’}

so you can add a ?.value to get the actual value “Italy“ from the field.

I hope this helps.

Please let me know if you have any other questions.

Kind regards,

Christophe De Beule

Hello @Christophe_De_Beule and thanks for answering.

I tried to set it this way you suggest:

The problem is things seem to work, I mean at first sync the issue is created on Jira’s side (the destination), the field is filled (I can see it in the Jira issue), but the sync doesn’t complete successfully and even though the field is filled I get that error.

I have a ticket open with support but they seem unable to sort that out either.

I’ve run out of ideas to try.

Thanks

Bumping back since even support seems unable to find what is wrong here.

Here’s a number of attemps:

Case 1 - following support’s suggestion with the code:

issue.customFields."Region".value = nodeHelper.getOption(replica.customFields."Region - BUE".value)
issue.customFields."Product Line - Tax&AMC".value = nodeHelper.getOption(replica.customFields."Product line - Tax&AMC -  BUE".value)

The error is:

No signature of method: jcloudnode.services.jcloud.hubobjects.NodeHelper.getOption() is applicable for argument types: (com.exalate.basic.domain.hubobject.v1.BasicHubOption) values: [BasicHubOption{id='37898341721617', value=italy_bue, sequence='null', disabled='null'}] Possible solutions: getOption(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.Long, java.lang.String), getOption(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.String, java.lang.String), getOption(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.Long, java.lang.String, boolean), getOption(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.String, java.lang.String, boolean), getOptions(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.Long, java.util.List), getOptions(com.exalate.api.domain.hubobject.v1_17.IHubIssue, java.lang.String, java.util.List)

Case 2 - While with the code:

issue.customFields."Region".value = replica.customFields."Region - BUE".value
issue.customFields."Product Line - Tax&AMC".value = replica.customFields."Product line - Tax&AMC -  BUE".value

The error is:

Could not create an work item with type `Service Request` on project `BUE`: Unable to create request because of these errors : Field with id 'customfield_11996' named 'Product Line - Tax&AMC' has these errors : Specify a valid value for Product Line - Tax&AMC, Field with id 'customfield_12060' named 'Region' has these errors : Specify a valid value for Region.

that looks like an improvement to me.

Case 3 - with the code

issue.customFields."Region".value = replica.customFields."Region - BUE"
issue.customFields."Product Line - Tax&AMC".value = replica.customFields."Product line - Tax&AMC -  BUE"

The error is:

com.exalate.basic.domain.hubobject.v1.BasicHubCustomField type cannot be assigned to custom field 'Region' of type select list.

Case 4 - with the code

issue.customFields."Region".value = replica.customFields."Region - BUE"
issue.customFields."Product Line - Tax&AMC".value = replica.customFields."Product line - Tax&AMC -  BUE"

The error is:

Request type `Backoffice & Reporting - Tax&AMC` requires a custom field 11996 of type `com.atlassian.jira.plugin.system.customfieldtypes:select` but none was set through exalate config.

Case 5 - Following your suggestion @Christophe_De_Beule with this code:

issue.customFields."Region".value = replica.customFields."Region - BUE"?.value?.value
issue.customFields."Product Line - Tax&AMC".value = replica.customFields."Product line - Tax&AMC -  BUE"?.value?.value

The error is:

Could not create an work item with type `Service Request` on project `BUE`: Unable to create request because of these errors : Field with id 'customfield_11996' named 'Product Line - Tax&AMC' has these errors : Specify a valid value for Product Line - Tax&AMC, Field with id 'customfield_12060' named 'Region' has these errors : Specify a valid value for Region.

(same as Case 2)

I’ve run out of options.

Here’s the related remote replica JSON:

{
  "version": {
    "major": 1,
    "minor": 14,
    "patch": 0
  },
  "hubIssue": {
    "voters": [],
    "fixVersions": [],
    "internalMap": {},
    "labels": [
      {
        "label": "backoffice_reporting_bue_tax"
      },
      {
        "label": "italy_bue"
      },
      {
        "label": "portale_tax_caf_bue"
      },
      {
        "label": "tax_amc_solution_bue"
      }
    ],
    "customKeys": {
      "isUnstaffedMode": false
    },
    "assignee": {
      "key": "377726464497",
      "active": false,
      "email": "a*****************com",
      "displayName": "a*****************com",
      "username": "a*****************com"
    },
    "entityProperties": {},
    "status": {
      "id": "open",
      "name": "open"
    },
    "components": [],
    "attachments": [],
    "customFields": {
      "Region - BUE": {
        "id": 37898341721617,
        "name": "Region - BUE",
        "uid": "37898341721617",
        "type": "OPTION",
        "value": {
          "id": "37898341721617",
          "value": "italy_bue"
        }
      },
      "Product line - Tax&AMC -  BUE": {
        "id": 37913472034449,
        "name": "Product line - Tax&AMC -  BUE",
        "uid": "37913472034449",
        "type": "OPTION",
        "value": {
          "id": "37913472034449",
          "value": "portale_tax_caf_bue"
        }
      },
      "Portale BUE": {
        "id": 37897940102289,
        "name": "Portale BUE",
        "uid": "37897940102289",
        "type": "OPTION",
        "value": {
          "id": "37897940102289",
          "value": "tax_amc_solution_bue"
        }
      },
      "Section Tax&AMC - BUE": {
        "id": 37913035628561,
        "name": "Section Tax&AMC - BUE",
        "uid": "37913035628561",
        "type": "OPTION",
        "value": {
          "id": "37913035628561",
          "value": "backoffice_reporting_bue_tax"
        }
      }
    },
    "eventTriggerContext": {},
    "description": "Prova 12 non considerare",
    "watchers": [],
    "key": "2087244",
    "summary": "Prova 12 non considerare",
    "comments": [],
    "reporter": {
      "key": "378609898417",
      "active": false,
      "email": "a***************com",
      "displayName": "A*********e",
      "username": "A*********e"
    },
    "workLogs": [],
    "affectedVersions": []
  },
  "issueUrl": "https://n******l.zendesk.com/agent/tickets/2087244"
}

After trying everything we lastly asked Exalate for paid support, and after a couple of long and difficult sessions with them, the key clue here seems to be this:

If the issue is created in Jira, then the incoming script on jira side has successfully completed.

Then the outgoing script (always on jira side) will be triggered, so to communicate to the other side, that is “waiting for remote”, the linked issue key.

So, surprisingly, the error was indeed in the outgoing script. Replacing it with a “vanilla” outgoing script allowed the sync to complete successfully.

I write it here in the hope this can help others.

BR