Hi Guys,
Could you please help to get parent id
import jira.client
from jira.client import JIRA
options = {'server': 'https://example.com', 'verify':False}
jira = JIRA(options, basic_auth=('user', 'password'))
issues_in_project = jira.search_issues('project=11372 AND SPRINT not in closedSprints() AND sprint not in futureSprints()')
for value in issues_in_project:
print value.key , value.id, value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels
Here, value.fields.id is showing child Id, I want the parent id as well.
For example- When we export jira details from jira by selecting all fields in CSV format..By automatically we get issue Id and corresponding parent id
I want to understand how it getting parent id from child (value.fields.id)
Is there any field through I can get directly.parent id ? Like any customfield or value.fields.parent something
Please have a look once and It will be very great if anyone can help on this
Thanks
Hi Himanshu,
I was scratching my head with this one for quite awhile, but I think I've figured out the issue here. Your query:
'project=11372 AND SPRINT not in closedSprints() AND sprint not in futureSprints()'
I suspect there are issues returned in those results that are not subtasks. Since those issues wouldn't have a parent ID, the print function fails. By adding try/except logic to the code, I was able to retrieve the parent ID for the subtasks included in the query.
Change your for loop to the following and see if that does the trick.
for value in issues_in_project:
try:
print value.key , value.id, value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels, value.fields.parent.id
except:
print value.key , value.id, value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.