Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

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

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!

3 answers

1 accepted

2 votes
Answer accepted
Muhammad Ramzan Community Leader Jun 03, 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

@Muhammad RamzanThank you for your answer, it is helpful, i appreciate it!

Like Muhammad Ramzan likes this
Muhammad Ramzan Community Leader Jun 03, 2021

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

0 votes
Iago Docando Community Leader Jun 03, 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)
}
}

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

0 votes
Jack Community Leader Jun 03, 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()

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 Community Leader Jun 03, 2021

Hmmm , what defines a sibling of a sub task?

Jack Community Leader Jun 03, 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

Suggest an answer

Log in or Sign up to answer
TAGS

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