ScriptRunner: cannot seem to make this work in JQL

Mircea Craciun
Contributor
June 6, 2024

Hello, I recently enable script runner and I'm trying to filter for ticket in epics with specific due date. I tried a few JQL like below

issue in allIssuesInEpic("duedate <= '2024-07-01'")

or

 

parent in issuesInEpics("duedate <= '2024-07-01'")

 

but jira complains there is no such function as the ones I named.
What do I need to do to enable script runner in JQL? And are those the actual functions for what I am trying to do?

Thank you

2 answers

1 vote
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2024

Hello @Mircea Craciun 

If you have just recently added the app to your instance, you must first execute the Synch function before you can successfully get results from your searches.

https://docs.adaptavist.com/es/latest/get-started/synchronising-keywords

 

Then, to create a filter that uses ScriptRunner functionality you must go to the Enhanced Search screen available from the Apps menu.

Screenshot 2024-06-07 at 8.45.59 AM.png

 

You can't use ScriptRunner functions directly in the View All Issues or other native Jira issue filtering screens.

https://docs.adaptavist.com/es/latest/run-a-search

 

Next, you need to use the correct function and syntax, which you can find in the app documentation.

https://docs.adaptavist.com/es/latest/run-a-search/jql-functions#issuesinepicssubquery

issuefunction in issuesInEpics("duedate <= '2024-07-01'")

Mircea Craciun
Contributor
June 10, 2024

@Trudy ClaspillThank you. I see on the enhanced search window "JQL Sync Status FULLY SYNCED" so I assume that is good.
Running your proposed query there though gets no results, yet we have a lot of epics with due date June 28th 2024 (some in progress, some todo, some done) and all our tickets (bugs, stories, tasks) are assigned to an epic. (also epics with Due Date later than July 1st 2024)

Any idea what could be wrong?

Thanks.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 10, 2024
Mircea Craciun
Contributor
June 10, 2024

@Trudy Claspill 

still no luck

Screenshot 2024-06-11 094304.png

 

Interestingly, if I try and add the same with the helper, it shows a partial result (there should be more) but when I added that to the list, it still results in 0.

Screenshot 2024-06-11 094655.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2024

I have had some oddities with the Enhanced Search sporadically where I have typed in the JQL directly on the screen but it says the JQL is invalid or gives an odd result. I've never figured out why.

But if I use the helper to create the same JQL, then it works.

When using the helper there is a button at the bottom right corner of the helper pop up to add the content of the helper to the query. Have you used that? The pop-up is too big to display entirely on my screen so I have to scroll down to see that button.

Screenshot 2024-06-14 at 10.11.30 AM.png

Mircea Craciun
Contributor
June 19, 2024

Yes, I have used the helper that way. Any idea what that "Team managed projects" notification is that is showing up? Clicking on more info just gets me to the blogs, and I don't know how to see if I'm hitting that "wall" or not.
Thanks

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 19, 2024

In Jira Cloud there are two over-arching project types - Company Managed and Team Managed. You can find out which type your project is by going to the View All Projects page under the Projects menu, finding your project in the list and looking at the Type column.

The query within the helper dialog gives you the same results as if you ran the identical query (duedate < '2024-07-10') in the regular issue search screen. It is not yet applying any other criteria to it related to the function that you want to use. You can click on the link to see the actual issues it has found based on that portion of the query.

Screenshot 2024-06-19 at 9.28.46 AM.png

 

Those results will include all issues of all types in all projects (to which you have access) that match the subquery.

When you then insert that subquery into the function, that applies another layer of criteria. In the case of the issuesInEpics function, you are getting the Epics that match the subquery first, and then getting all the child issues in those Epics as the final results.

However, if any of those Epics are in Team Managed projects, they and their child issues will be excluded.

If you think you have an Epic that matches the subquery, that has child issues that should be in the results set, and that Epic (and the child issues) are not in a Team Managed project, can you share screen images of that Epic showing the due date and the child issues?

0 votes
Lígia Zanchet
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 14, 2024

hi Mirceao

I don't know if you follow this instruction here on how to add the functions to the JQL search: 

https://docs.adaptavist.com/sr4js/latest/features/jql-functions

Thanks 

Mircea Craciun
Contributor
June 19, 2024

Yes, I have. But the documentation there is misleading/incorrect. If you read the page it clearly says "You can use ScriptRunner JQL functions anywhere you are able to use Jira JQL functions" So I go to issue search, where I can use Jira JQL, copy the code form their example on that very page that reads

  • Use issuesInEpic to find all stories for open epics in a project, and then look specifically at the status of issues, such as ‘in progress.’

And I get
Screenshot 2024-06-19 122712.png

If I go to `ScriptRunner Enhanced Search` as suggested by Trudy above, you can see my problem, with the helper showing 31 results but actually running it returning 0.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events