1

We have a custom field within jira service desk which holds the organization. Currently I'm trying to return the organization from the issue object returned by my jira search.

However when i try to do this, I just get a class, and i'm unable to see what the object value of the organization is.

tried var() and various other methods, tried .name which works for others, or .value etc.

import sys
from collections import Counter
from jira import JIRA

#Changes the default server to the below server
options = {
    'server': 'myserver',
    }
#Writes the above changes to the JIRA module with the username and password for authentication
jira = JIRA(options,basic_auth=(username,pw))

#Search Query, this can be very similar to the same search query you'll type within Jira
issues_in_proj = jira.search_issues('project=FUD', maxResults=1)

#All issues returned are objects, this means they contain all the fields attached to them.
#They can be accessed via a loop and via the fields varible. e.g issue.fields.summary
for issue in issues_in_proj:
    print issue.fields.customfield_13000

I would like it to return the value as almost every other field does.

Ruben Bob
  • 91
  • 1
  • 9

4 Answers4

2

I don't know how to get this when the results are returned as a "ResultsList" which is the default.

However you can request the the results are returned as a dict, which is how I've solved this issue.

jira.search_issues('project=FSD', maxResults=1,json_result=True)

https://jira.readthedocs.io/en/master/api.html?highlight=dict

json_result (bool) – JSON response will be returned when this parameter is set to True. Otherwise, ResultList will be returned.

Ruben Bob
  • 91
  • 1
  • 9
1

you can also use

for issue in issues_in_proj:
    print (issue.fields.customfield_13000[0].id)
    print (issue.fields.customfield_13000[0].name)
Danijel
  • 11
  • 1
0

In my case, it was necessary to configure the field to be read in all jira projects, because I was trying to read a field that did not belong to the read project.

Field configured to be used in all projects.

0

You can check the attributes of the query and specific field then just extract what you need.

YourQuery = jira.search_issues(QUERY, maxResults=0)

for issue in YourQuery:
print(issue.fields.customfield.__dict__)

In my case I extracted the data in a dictionary.

for issue in jira_issues_Clex_Outflow:
d = {
'CustomName':  issue.fields.customfield.AttributeCustomField
 }