Jira filter to see all sub-tasks in a story or task when minimum 1 sub task is assigned to me

Ghina Dernaika June 3, 2021

Hi,

Anyone can help me in writing a JQL query in jira in which i can see all the task/stories assigned to me, and additionally all sub-tasks (for me and others) in a story, when minimum 1 sub-task in that story is assigned to me.

 

Any help is appreciated!

Thank you in advance!

4 answers

1 accepted

2 votes
Answer accepted
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.
June 3, 2021

Hi @Ghina Dernaika ,

As explained by others , its not possible with Vanilla JQL. I can see you have selected the cloud so here are few ways to achieve your goal

 

1- Used an extension like JQL Search Extensions for Jira & reports ,  one of my favorite adon for JQL

it will get all parent tasks which have sub tasks and current users is the assign of the sub tasks. You can simply filter it further to refine the results or can add more users for assignee comparison

issue in parentsOfIssuesInQuery("assignee=currentUser()")

 

2- Use Jira automation , its not a clean way but it can solve your problem somehow

You can further play with this rule to add more people 

subtasks.png

Ghina Dernaika June 3, 2021

@Muhammad Ramzan(Atlassian Certified Master)Thank you for your answer, it is helpful, i appreciate it!

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.
June 3, 2021

My pleasure,  happy to know it helped and many thanks for confirmation

0 votes
Steffen Brahtz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 9, 2024

Seems they have added new functionality. Was able to do this:

issueFunction in SubtasksOf ("issueFunction in parentsOf ('assignee=jdoe')")

Antonius Golly April 11, 2024

Can you share more details on where you used that? It doesn't seem a valid JQL query.

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2021

Are you asking to find all issues assigned to you in the current Sprint? If so does the following accomplish your goal?

project = abc and assignee = currentuser() and sprint in opensprints()

Iago Docando
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.
June 3, 2021

I believe she seeks for a JQL that returns tasks and subtasks assigned to her AND ALSO any subtask not assigned to her but that is a "sibling" of a subtask assigned to her. I don't think there's a solution for that in cloud

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2021

Hmmm , what defines a sibling of a sub task?

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2021

Oh OK I see what you’re saying it’s another sub task that is associated with the same story

Like Iago Docando likes this
0 votes
Iago Docando
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.
June 3, 2021

Vanilla JQL can't do this. You need to search for all your assigned tasks/subtasks, then check the parent task of every subtask assigned to you and finally retrieve every subtask hanging from those parents, regardless of the assignee.

In cloud I don't know how to extend JQL capabilitties. I've done that in the past in SERVER using the plugin myGroovy, wich allowed me to write my own custom JQL functions.  I'll share with you what I came up with just in case you can use it down the road. In my case I needed to get every task/subtask matching certain criteria but also any subtask whose parent task matched that criteria.

If you find a way to obtain your custom JQL functions I'm sure you'll be able to use this as a template. Best of luck.

 

import com.atlassian.jira.JiraDataType
import com.atlassian.jira.JiraDataTypes
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.search.SearchQuery
import com.atlassian.jira.jql.operand.QueryLiteral
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.jql.query.IssueIdCollector
import com.atlassian.jira.jql.query.QueryCreationContext
import com.atlassian.jira.jql.validator.NumberOfArgumentsValidator
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.util.MessageSet
import com.atlassian.jira.util.MessageSetImpl
import com.atlassian.query.clause.TerminalClause
import com.atlassian.query.operand.FunctionOperand
import ru.mail.jira.plugins.groovy.api.jql.ScriptedJqlValuesFunction

class DemoFunction implements ScriptedJqlValuesFunction {

@Override
public JiraDataType getDataType() {
return JiraDataTypes.ISSUE;
}

@Override
public MessageSet validate(ApplicationUser searcher, FunctionOperand operand, TerminalClause terminalClause) {
def i18n = ComponentAccessor.getI18nHelperFactory().getInstance(searcher)
def numberValidMessage = new NumberOfArgumentsValidator(1i, i18n).validate(operand);
if (numberValidMessage.hasAnyErrors()) {
return numberValidMessage
}
def messageSet = new MessageSetImpl();
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
try {
def query = jqlQueryParser.parseQuery(operand.getArgs().get(0))
} catch (any) {
messageSet.addErrorMessage("not valid jql:${operand.getArgs().get(0)}");
messageSet.addErrorMessage("${any}");
}
return messageSet
}

List<QueryLiteral> getValues(QueryCreationContext queryCreationContext, FunctionOperand functionOperand, TerminalClause terminalClause) {
final List<QueryLiteral> literals = new LinkedList<>();
String jql = functionOperand.getArgs().get(0)
getIssuesByJQL(jql, queryCreationContext.getApplicationUser()).each { issue ->
literals << new QueryLiteral(functionOperand, issue.key)
issue.getSubTaskObjects().each { subTask ->
literals << new QueryLiteral(functionOperand, subTask.key)
}
}

return literals
}

private Collection<MutableIssue> getIssuesByJQL(String jql, ApplicationUser user) {
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)

def query = jqlQueryParser.parseQuery(jql)
SearchQuery searchQuery = SearchQuery.create(query, user)
IssueIdCollector collector = new IssueIdCollector()
searchProvider.search(searchQuery, collector)
return collector.getIssueIds().collect { getIssue(it as Long) }
}

private MutableIssue getIssue(Long id) {
ComponentAccessor.issueManager.getIssueObject(id)
}
}
Ghina Dernaika June 3, 2021

Thank you for your answer, it could be difficult, but i can try. Thanks for sharing me the code. i appreciate it.

Ladislav Kočiš January 10, 2023

I have just learned a very easy way how to do it. 

sprint = (SprintNumber) and parent = (UserStoryNumber/name) and assignee = "Username"

 

you can try many different ways but remember, easiest way is the correct one. :D

Suggest an answer

Log in or Sign up to answer