In this article, we will go further into JQL searches by exploring the Jira search functions that allow you to enrich and variabilize your queries.
It is already possible to make queries variable with the classic search. For example, " current user " allows you to refer to the connected user and therefore with the same query, have different behaviors depending on the person who executes it. In the same way, we can make sliding searches. For example, we can search for requests from the last 30 days. But we can't search for requests created since the beginning of the week or the month. So, we could search for the requests created since the beginning of the month or we could put a hard date, the 1st of May for example. But the following month, this will not work anymore and we will always retrieve the requests from May 1st.
The search functions in Jira
Jira therefore offers a set of functions that enable these needs to be met. They are of several types. Some functions are relative to the date, like the beginning of the week, the beginning of the day, the beginning of the month, relative to the current time, relative to my last connection date.
Other functions refer to users. We have already seen the currentUser() but it can also be membersOf() for users belonging to a group. It can also be functions that are related to versions, so the requests that are requested in the next planned version. It can also be functions associated with the links between requests. For example, you can search for all the requests related to another request in particular. There are still other types of functions, some of which are specific to Jira Software or Jira service desk.
I won't go through them all here because the Atlassian documentation is very complete and exhaustive on the subject. Instead, I will take a few examples.
First example: how to find all the requests solved last month?
For this search, we will use the "creation date" criterion and ask for all the requests created after the beginning of the previous month.
The beginning of the previous month is written as " StartOfMonth " with minus 1 in parenthesis:
createdDate > = startOfMonth(-1)
The start of the current month would be startOfMonth() with no value between the parentheses, and the start of the next month would be startOfMonth(1).
If we want to search two months back, we put -2 between the brackets: startOfMonth(-2).
Second example: How do I find all the requests created since my last connection?
If I want to find all the requests created since my last connection, the query to enter is the following:
createdDate > lastLogin()
If I want to know the requests created since the time of my current connection, I can use :
createdDate > currentLogin()
Third example: how can I find the whole list of requests assigned to Jira administrators?
The appropriate query will be :
assigned in membersOf("jira-administrators")
We could also find requests that would be assigned to inactive users. In this case, the request would be :
assigned in inactiveUsers()
In this example, I don't have any, which is rather good news.
Fourth example: how to find all the requests for a future version?
I might also want to find all the requests in the next version to be released. The criterion I would use to search is fixed version or fixVersion. In this case, the query is :
fixVersion = earliestUnreleasedVersion()
Fifth example: how to find all the requests blocked by another request?
How can I find all the requests that are blocked by another one? To do this, you need to know the key of the request and use the following query:
Issue in linkedIssues, the reference of the request and the link I want to test.
Issue in linkedIssues("PLAT-1", "Block")
I hope that by now you are more familiar with the use of Jira search functions in JQL. Don't hesitate to test, because once again, you won't break anything. In the next article we will see how to search Jira histories.