how to get stories list which are not in closed state and task relates to story (same) is closed sta

Suryaprakash Thonupunuri January 20, 2020

how to get stories list which are not in closed state and task relates to story (same) is closed status.

 

For a given project in JIRA, wanted to get the list of stories are not closed but tasks relates to this story got closed. 

In my project story contains multiple tasks, each task handled by different user, as and when tasks are in closed status, we should change Story status to close.  wanted to get the list of stories which are not closed but Task (issue type) relates to this story are in closed state.

 

Query: project = "Project name" AND type = Story ) AND assignee = current user  AND status != Closed , and have analyse each story and change to close. So looking for option here . this Query gets stories but wanted stories and tasks of that stories in closed status.

6 answers

1 accepted

0 votes
Answer accepted
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2020

So, if you can't use an addon, i will suggest you to use jira python, here a code that i tried today (i'm not an expert but it's working)

 

from jira import JIRA


jira_cloud = JIRA(basic_auth=("username", 'token_cloud'), options={'server': 'https://jira_url/'})
issues_Jql = 'project = "ABC" and type = story'
my_issue = jira_cloud.search_issues(issues_Jql)


issue_list = []

for story in my_issue:
for issue_task in story.fields.issuelinks:
if hasattr(issue_task,"inwardIssue"):#look for the inward linked (the task issue type)
linked_task = jira_cloud.issue(issue_task.inwardIssue.key)
if str(linked_task.fields.status) == "To Do":#status name that i'm looking for
issue_list.append(story.key)
issue_list.append(linked_task.key)




key_list = ""

for i in issue_list:
key_list= key_list + i+","

key_list = key_list[:-1]#remove the last comma


jql_list = f"project = ABC AND issuekey in ({key_list})"
print (jql_list)

This code will return a jql with the story and linked task that are in to do status.

 

Or you can use google sheet and use 2 different jql one for the story and another one for the task and work on it to have everything in one sheet.

https://community.atlassian.com/t5/Jira-articles/Jira-Cloud-for-Google-Sheets-Automatically-Refresh-Your-Data/ba-p/1200264

 

Hope this helps

Suryaprakash Thonupunuri January 24, 2020

Thank you @Mohamed Benziane  , it is helping some extent. little work around but great helps. thank a lot.

Suryaprakash Thonupunuri February 5, 2020

Thanks @Mohamed Benziane  @Indu with PIP we are success .

 

global str
from jira import JIRA
jira = JIRA(basic_auth=("user ID", 'password'), options={'server': 'https://jira.xyz.com'})
for issue in jira.search_issues('project = XX AND type = "Story" AND assignee = "current User" AND status != "Closed" AND labels = new', maxResults=100):
if (issue.fields.issuelinks):
#print('{}: {}'.format(issue.key, issue.fields.status))
if str(issue.fields.status) != "Closed":
for links in issue.fields.issuelinks:
if hasattr(links, "outwardIssue"):
outwardIssue = links.outwardIssue
if str(outwardIssue.fields.status) != "OPEN":
print(outwardIssue.key,outwardIssue.fields.status,issue.key,issue.fields.status)

0 votes
Suryaprakash Thonupunuri January 24, 2020

apart from Add-on, any other solution? 

0 votes
Muhammad Ramzan(Atlassian Certified Master)
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.
January 21, 2020

a third part plugin JQL Search Extensions for Jira & reports is available on Cloud which can solve your issue.

 

 

I create your scenario and its successfully returning the results.

What you need to do is.

  • Create one sub query "issuetype= Story and status= "closed""
  • Then use this query to get your results.
(subTaskOfQuery="subquery" and status="closed") or issuesInQuery="subquery"

Please note that "subquery" is the alias of the sub query. This query will return 

stories list which are not in closed state and task relates to story (same) is closed status.

 

 

Here is the documentation , how to use it

https://jqlsearchextensions.atlassian.net/wiki/spaces/SEARCH/pages/173211649/Subqueries+-+Jira+Cloud

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 21, 2020

Hello,

The task are linked to your storie ? So to achieve what you want you'll need a plugin like Scriptrunner:

https://scriptrunner.adaptavist.com/4.3.4/jira/jql-functions.html#_linkedissuesof

It provides a JQL function that find linked issue with specific status.

 edit : As @Lenin Raj asked, if by task you meant subtask you will also need an addon like scriptrunner too.

https://scriptrunner.adaptavist.com/4.3.4/jira/jql-functions.html#_hassubtasks

Hope this helps.

Suryaprakash Thonupunuri January 24, 2020

Thank you, Im not looking any add-on. Add-on required to add by Admin/Dev ops. this is forbidden in my case.

0 votes
Lenin Raj
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2020

Hi @Suryaprakash Thonupunuri 

When you say 'tasks', do you mean 'sub tasks'?

Suryaprakash Thonupunuri January 21, 2020

jira atlassian.png

@Lenin Raj it is not the sub tasks,. it is issue type =task (in my project) and we are using option called "relating to" as shown in picture.. any comments

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 21, 2020

Ok, so you will need an-addon, you can look at my answer below.

Suryaprakash Thonupunuri January 24, 2020

Thank you, im not looking any add-on. Add-on required to add by Admin/Dev ops. this is forbidden in my case.

Suggest an answer

Log in or Sign up to answer