JQL sub-query

Hello. I am using Script Runner. 

I am writing to ask you for a piece of advise. 
My ultimate goal is issuing a subquery.

I am trying to implement a custom JQL function. It's going to be called
filterQuery(). 
It's supposed to take 1 argument - some JQL query and return issues.

It's use-case is in the following example:
issuetype = epic and issuekey in filteryQuery("project = MYPROJ")

But unfortunately, it's impossible to use own functions with 'issuekey in'. But, when used with the IN or NOT IN operators, issueKey supports:
issueHistory()
linkedIssues()
votedIssues()
watchedIssues()

So, can I expand that list of functions about with my own one using Script Runner?
Thanks a lot.

1 answer

Hi,

You cannot extend the functions supported by the IN operator using the Script Runner. What you can do is write your own function and use that, such as

issueFunction in yourOwnFunction()

What exactly are you trying to accomplish with your filterQuery function?

Regards,

Geert

Basically, I am looking for subquery functionality in JQL. I think I need to write my own function here.

Good to have jira function (let's name it like filterResult), that will add an ability to do subquery in JQL. Example jql1: project = CM jql2: project = IDS and issuetype = Epic and linkedIssues in filterResult(jql1) - to show all issues in IDS project that have links to issues from CM project jql3: project = CM and EpicLink in filterResult(jql2) and linkedIssues in filterResult("resolved < -2d") - for CM issues with epics from IDS, matching jql2 and linked with issues that was resolved less then 2 days ago.

I think you can do a lot of what you want with the already available JQL functions in Script Runner, for example: jql2: project = IDS and issuetype = Epic AND issueFunction in linkedIssuesOf("project = CM", "<link name>") (I am not able to test this right now). Also be sure to have a look at the complex examples, which show how you can use filters: https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+JQL+Functions#ScriptedJQLFunctions-MoreComplexExamples.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

174 views 1 17
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you