"Custom field with id <id> doesn't exist"

Hi,

For context, I’m trying to implement a searchable custom field in Jira. My understanding is that I need to update the custom field value via the API to achieve this. My code snippet is as follows:

const context = useProductContext()
let value = "foo"
const response = await api
  .asApp()
  .requestJira(route`/rest/api/3/app/field/${context.extensionContext.fieldId}/value`, {
    method: 'PUT',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: `{
        "updates": [
          {
            "issueIds": [
              ${context.platformContext.issueId}
            ],
            "value": ${value}
          }
        ]
      }`
  });

Unfortunately, when trying to use the example code provided I receive an error that "Custom field with id 'customfield_10100' doesn't exist." This is despite being able to verify that the custom field definitely exists in my test instance according to the /field API, as follows:

{
  id: "customfield_10100",
  key: "<apikey>__DEVELOPMENT__<appname>",
  name: "foo",
  untranslatedName: "foo",
  custom: true,
  orderable: true,
  navigable: true,
  searchable: true,
  clauseNames: [
    "cf[10100]",
    "foo"
  ],
  schema: {
    type: "object",
    custom: "<localId>",
    customId: 10100,
    configuration: {
      customRenderer: true,
      readOnly: true,
      environment: "DEVELOPMENT"
    }
  }
}

Could anyone provide any insight as to what might be causing this?

1 Like

Can anyone assist?

Hi @BradQ ,

I tried replicating this behavior by creating a read-only jira:customField of type object, but my calls to PUT /rest/api/3/app/field/${context.extensionContext.fieldId}/value were successful (HTTP 204). In order to have more context, can you share your manifest, specifically the jira:customField module?

The only thing I updated from your snippet is let value = "foo" since you are assigning a string where a JSON object is expected (with the assumption that your customfield’s data type is object based on the results of your GET /rest/api/2/field) but this should be a different error (HTTP 400) and not the one you are getting.

Cheers,
Ian

Hi Ian,

Manifest is as follows:

modules:
  jira:customField:
    - key: <key>
      name: <name>
      description: <description>
      type: object
      formatter: 
        expression: "`${value}`"
      validation:
        expression: value == null || !!value.match("^[A-Za-z]+$")
        errorMessage: <errormsg>
      readOnly: true
      function: foo
  function:
    - key: foo
      handler: index.runView
app:
  id: <appid>
permissions:
  scopes:
    - read:issue-meta:jira
    - read:issue-security-level:jira
    - read:issue.vote:jira
    - read:avatar:jira
    - read:issue:jira
    - read:status:jira
    - read:user:jira
    - read:field-configuration:jira
    - read:issue.changelog:jira

FYI I’m also unable to install Forge apps on my test instance at the moment, even blank ‘hello world’ ones. The error message I’m getting is as follows:

Installing your app on to development...

  ▶️  GraphQL https://api.atlassian.com/graphql
Query:
      query forge_cli_getCloudIfForTenantContexts($hostNames: [String!]) {
        tenantContexts(hostNames: $hostNames) {
          cloudId
        }
      }

Variables: {
  "hostNames": [
    <instance_url>
  ]
}
  ◀️  GraphQL
Request ID: 1c819f9f0e9cf726
Result: {
  "tenantContexts": [
    {
      "cloudId": "<cloudId>"
    }
  ]
}
  ▶️  GraphQL https://api.atlassian.com/graphql
Query:
      mutation forge_cli_installApplication($input: AppInstallationInput!) {
        installApp(input: $input) {
          success
          taskId
          errors {
            message
            extensions {
              errorType
            }
          }
        }
      }

Variables: {
  "input": {
    "installationContext": "ari:cloud:jira::site/<cloudId>",
    "appId": <appid>,
    "environmentKey": "default",
    "async": true
  }
}
  ◀️  GraphQL
Request ID: a36e7c17fc144ab2
Result: {
  "installApp": {
    "success": true,
    "taskId": "86b7ad20-f043-4cd5-96e3-9c692ddf8142",
    "errors": null
  }
}
  ▶️  GraphQL https://api.atlassian.com/graphql
Query:
      query forge_cli_getInstallationTask($id: ID!) {
        appInstallationTask(id: $id) {
          state
          errors {
            message
            extensions {
              errorType
            }
          }
        }
      }

Variables: {
  "id": "86b7ad20-f043-4cd5-96e3-9c692ddf8142"
}
  ◀️  GraphQL
Request ID: 40774183d4eeff0
Result: {
  "appInstallationTask": {
    "state": "PENDING",
    "errors": null
  }
}
  ▶️  GraphQL https://api.atlassian.com/graphql
Query:
      query forge_cli_getInstallationTask($id: ID!) {
        appInstallationTask(id: $id) {
          state
          errors {
            message
            extensions {
              errorType
            }
          }
        }
      }

Variables: {
  "id": "86b7ad20-f043-4cd5-96e3-9c692ddf8142"
}
  ◀️  GraphQL
Request ID: 5106a043fafb869b
Result: {
  "appInstallationTask": {
    "state": "FAILED",
    "errors": [
      {
        "message": "An unexpected error occurred",
        "extensions": {
          "errorType": "INTERNAL_SERVER_ERROR"
        }
      }
    ]
  }
}

This is interesting, @BradQ, as I cannot replicate the issue. I created a new app from scratch, copied the scopes you provided for consistency, and was able to install it on my instance; the PUT /rest/api/3/app/field/${context.extensionContext.fieldId}/value call was also successful.

Based on the error you shared (with the assumption that these logs came from forge install --verbose), it might be an instance related issue. If Forge app installation continues to fail on your instance, feel free to raise this issue in Developer Support Service Desk.

Also, I edited your previous message to remove cloudId since I noticed that you also removed information like hostname and such.

Thanks @iragudo, I’ll see if the support desk can sort out my instance / installation issues first.

1 Like