Get child details from parent field.subtaks using python

Himanshu_Pant April 22, 2018

Hi Guys,

 

I am using this to get parent details only and last field is a subtask which will tell about parent's child key and id.

I want to get details of child subtask as well like assignee, reporter, timespent etc.

Below Code:-

issues_in_project = jira.search_issues('project=11372 AND SPRINT in openSprints() and sprint not in futureSprints() and issuetype not in subTaskIssueTypes()',maxResults=1000)

 

for value in issues_in_project:
print value.key,
value.fields.summary,

value.fields.assignee,

value.fields.reporter,
value.fields.subtasks,

 

 

Result :-

1147, assignee_name, reporter_name, Subtask
[<JIRA Issue: key=u'DW-1150', id=u'2278424'>, <JIRA Issue: key=u'DW-1151', id=u'2278425'>, <JIRA Issue: key=u'DW-1152', id=u'2278429'>, <JIRA Issue: key=u'DWD-1153', id=u'2281635'>]

Whatever output is getting from value.fields.subtasks, based on that I want child details with some parent details Like below.

Expected result:-

Parent_key,Parent_assignee,parent_reporter,child_key,child_assignee,child_timespent,child_summary

1147,assignee_name,reporter_name,1150(child_key),child1_username,1600(child1_timespent),summary(child1_summary_details)

1147,assignee_name,reporter_name,1151(child_key),child2_username,2400(child1_timespent),summary(child1_summary_details)

 

 

Could you please suggest on this how to achieve this?

 

Thanks,

 

 

 

2 answers

1 vote
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2018

Hi Himanshu

Within your current loop around issues, you need to add another loop to get the ID of each sub-task, then run a query for each one. So

for value in issues_in_project

     parentID = ...

     for subtasks in value.fields.subtasks

               subtaskID = subtasks.key

               get subtask details with another query for each subtaskID

 

Hope this helps

0 votes
Himanshu_Pant April 22, 2018

@Shaun S @Warren @Andy Heinzer Could you please suggest here your valuable  comments.

Suggest an answer

Log in or Sign up to answer