[Jira Forge] Changing the Value of a Custom Field from a Trigger doesn't work

Hi everyone,

I have a Jira forge app, which defines a custom field in its manifest:

...
  jira:customField:
    - key: attachments-metadata
      name: AttachmentsMetadata
      description: Attachment Metadata
      type: object
      schema:
        properties:
          attachmentNames:
            type: array
            items:
              types: string

Whenever I retrieve an issue via the REST API, I can see that the value of this field is null and its id is customfield_10044.

Then I try to set the value for this field from a trigger function like this:

await api.asApp().requestJira(route`/rest/api/3/issue/${issueId}`, {
    method: "PUT",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ fields: { "customfield_10044": {"attachmentNames":["test.pdf"]}  } }),
  });

However, this fails with the following error:

400 Bad Request
{"errorMessages":[],"errors":{"customfield_10044":"Field 'customfield_10044' cannot be set. It is not on the appropriate screen, or unknown."},"reasons":[]}

Why can’t I set the value of a custom field which is defined in the same forge app? Can triggers update issues’ custom field values?

Hey @GeoSystems,

To update a field with the API you’re using, the field needs to be available on the edit issue screen. If you want to bypass that requirement, you can use the API designed specifically for updating app fields: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-values--apps-/#api-rest-api-3-app-field-fieldidorkey-value-put.

2 Likes