Getting the value of a customfield by name

Hi everyone,
I am trying to make a issue panel that displays the whole address of an issue. I want to get the value of the customfield ‘Address’ by name. So instead of calling it by the customfield id as shown in the example below, i want to do something like data.fields.address. Are there rest-api calls or methods that achieve this?

This is the code i have so far.

import Resolver from '@forge/resolver';
import api, { route } from '@forge/api';
const resolver = new Resolver();

resolver.define('fetchAddress', async (req) => {
  const key = req.context.extension.issue.key;

  const res = await api.asUser().requestJira(route`/rest/api/3/issue/${key}`);

  const data = await res.json();
  const address = data.fields.customfield_10048;

  return address;

export const handler = resolver.getDefinitions();

Welcome to the Atlassian Developer Community, @JensSlofstra!

Unfortunately, I am not aware of such an API. Is there a specific use case you have in mind?

In case the use case is related to installing in multiple Jira sites and resulting in varying custom field (CF) IDs, I suggest doing a call to Get fields paginated and passing the CF name in query e.g., GET /rest/api/3/field/search?query=address which will give you something like

    "maxResults": 50,
    "startAt": 0,
    "total": 1,
    "isLast": true,
            "id": "customfield_10089",
            "name": "username",
                "type": "string",
                "custom": "com.atlassian.jira.plugin.system.customfieldtypes:textfield",
                "customId": 10089
            "description": ""

From the response, you can get the CF IDs based on the CF name. You would now be able to handle multiple sites and there’s no need to hard code the CF ID.

Hope this helps,

1 Like