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!
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
@Muhammad Ramzan(Atlassian Certified Master)Thank you for your answer, it is helpful, i appreciate it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My pleasure, happy to know it helped and many thanks for confirmation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems they have added new functionality. Was able to do this:
issueFunction in SubtasksOf ("issueFunction in parentsOf ('assignee=jdoe')")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share more details on where you used that? It doesn't seem a valid JQL query.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmmm , what defines a sibling of a sub task?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh OK I see what you’re saying it’s another sub task that is associated with the same story
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your answer, it could be difficult, but i can try. Thanks for sharing me the code. i appreciate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.