Update read only custom issue field

Hi - I am trying to update an issue field via the cloud API. I can do this without a problem when the field type is editable - but as soon as I declare the field type as read_only in atlassian-connect.json I am unable to write to it using the API

"jiraIssueFields": [
                "name": {
                    "value": "Read Only Custom Field"
                },
                "description": {
                    "value": "Display a searchable read only value for the current issue"
                },
                "type": "read_only",
                "key": "read-only-key",
                "property": {
                    "path": "myobj.name",
                    "key": "read-only-key",
                    "type": "string"
                  }
            }
        ],

Calling the Edit Issue endpoint: PUT /rest/api/3/issue/{issueIdOrKey}
with the following JSON:

{ "fields": { "app_key__read_only_key": "Read only value" } }

I get the following error:

{
    "errorMessages": [],
    "errors": {
        "customfield_10050": "Field does not support update 'customfield_10050'"
    }
}

Any guidance greatly appreciated

1 Like

:upside_down_face: Oh I get it now… so I worked this out I think… read only custom fields can not be directly updated via the API. Rather, they serve as a reference or pointer to map another issue property. The mapped property can be either an existing issue property or in my case, an entity property created by the app… which can be updated via the API

So first I declare an Issue Entity Property

"jiraEntityProperties": [
            {
              "keyConfigurations": [
                {
                  "extractions": [
                    {
                      "objectName": "userId",
                      "type": "string",
                    },
                    {
                      "objectName": "someValue",
                      "type": "string",
                    },
                  ],
                  "propertyKey": "my-property-key"
                }
              ],
              "entityType": "issue",
              "name": {
                "value": "My extra property"
              },
              "key": "my-property-key"
            }
          ],

And then declare a read-only custom field that maps to a path on my entity property

"jiraIssueFields": [
            {
                "name": {
                    "value": "My read only custom field"
                },
                "description": {
                    "value": "Read only display of my entity property"
                },
                "type": "read_only",
                "key": "my-read-only-field-key",
                "property":{
                    "path": "name",
                    "key": "my-property-key",
                    "type": "string"
                  }
            }
        ],

Hope this helps someone…

1 Like