It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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

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

Hi @Suryaprakash Thonupunuri 

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

jira atlassian.png

@Lenin_Raj_Rajasekaran 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

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

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

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_Rajasekaran 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.

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

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

apart from Add-on, any other solution? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Keep your team in the loop with Team @mentions in Jira Software!

Hi everyone! My name is Jenny, a Product Manager at Atlassian. After launching Team @mentions in Confluence, we heard a lot of positive feedback from customers that they love how easy it is to @men...

589 views 6 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you