user3100446
user3100446

Reputation: 41

How do I get display names from a custom field in Jira-python?

I am using the jira rest api in python (jupyter notebook) and want to get the display name of a custom field from Jira.

The custom attribute I am using represents Team Name in Jira. ex. 202 = "A Team", 204 = "The Brew Team", etc.

when I for loop I am able to get team id's but I'd like to get the display names ("A Team", "The Brew Team", etc.)

for item in project:
    team = item.fields.customfield_26588
    print(team)

Is there a way to get the actual display names from the custom field programatically?

Upvotes: 1

Views: 4542

Answers (2)

pelos
pelos

Reputation: 1876

Jira issue doesn't hold that information, jira instance does, since they associate the field with the issueType

you can get ALL the fields form the jira Instance, and match them against the ones in the issue with the id.

jira = JIRA(server=SERVER, basic_auth=(USER, PW))
issue_x = jira.issue("TEST-101")

all_the_fields = jira.fields()
for i in all_the_fields:
    for xx in issue_x.raw['fields']:
        if i["id"] == xx:
            print(i)

Upvotes: 1

Gorav Singal
Gorav Singal

Reputation: 538

Object of custom field looks like:

"customfield_1234": {
  "required": false,
  "schema": {...},
  "name": "Name",
  "allowedValues": [...]
}

If you want to have name of the custom field itself, you can get it from 'name' attribute of object. So, in your code you need to use:

print team.name

Upvotes: 0

Related Questions