Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom variable for JQL

RJ February 17, 2022

Hi

I am looking for a way to create custom variable like currentuser() for project. 
So we can use same filter across multiple projects. 
Variable would be like currentproject()

Is there we can create that? 

thanks

2 answers

0 votes
Nic Brough -Adaptavist-
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.
February 18, 2022

Welcome to the Atlassian Community!

currentUser() is a function, and you can create your own functions by writing apps to provide them.  https://developer.atlassian.com/server/jira/platform/adding-a-jql-function-to-jira/ is how to do it by hand, but there are a couple of apps in the marketplace that allow you to do it without needing to write your own app (Scriptrunner is the one I use, obviously, as I work for the vendor)

However, you won't be able to write a useful one for "current project".  JQL executes outside a project context and your function will always return "none"

0 votes
Ankit Srivastava
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.
February 17, 2022

Hi @RJ ,

currentuser() is a Jira's built-in JQL function and it is not possible to create currentproject() kinda function because logically it is not possible.

More details for JQL, please refer below link:

https://support.atlassian.com/jira-service-management-cloud/docs/use-advanced-search-with-jira-query-language-jql/




https://scriptrunner.adaptavist.com/latest/jira/tutorials/jql-functions-tutorial.html

 

If you want to fetch any specific issues from JIRA via JQL, please do let us know.

Hope this will help.

Regards,
Ankit Srivastava

Suggest an answer

Log in or Sign up to answer