Forums

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

Scriptrunner enhanced query - Finding tickets with links to another project

Ashbal December 23, 2022

I am using Jira cloud. We have Scriptrunner Enhanced Search. I have 2 projects.

Project 1 - Lets call pr1
Project 2 - Lets call pr2

I have a list of pr1 tickets (pr1-1, pr1-2 etc) and out of these tickets, I want to find the tickets that have a link to pr2 project. 

In my scriptrunner enhanced query, I am doing the following

key in (pr1-1, pr1-2) and issueFunction IN linkedIssuesOf("project = pr2")

I get 0 results eventhough pr1-1 has a link to pr2. 

Anything wrong in my query ?

2 answers

0 votes
Vamsi Kandala
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.
December 23, 2022

Hi @Ashbal

Like @Trudy Claspill mentioned, it is working for me as well and nothing wrong with the query.

Please double-check the ticket keys you have given in the query.

Thanks,
Vamsi

0 votes
Trudy Claspill
Community Champion
December 23, 2022

The function is working correctly for me.

Can you provide a screen image that shows the Linked Issues section for one or more of the "pr1" issues from your list, showing that it is linked to an issue in the "pr2" project?

Ashbal December 23, 2022

So in my example,

pr1-1 ticket has a link to pr2 project. The link in pr1-1 is shown below 

 


image.png

The query that i am running in Scriptrunner is 

key in (pr1-1) and issueFunction IN linkedIssuesOf("project = pr2")

and i get 0 results when I expect the result to show pr1-1

Trudy Claspill
Community Champion
December 23, 2022

There doesn't appear to be anything wrong with your filter. 

Are PR1 and PR2 projects Company Managed or Team Managed?

What happens if you remove the "key in..." clause? Does the output include pr1-1? Do you get any issues at all in the output?

Maybe you have a typo somewhere in the keys in your list or in the "project=" subquery. Can you show us the actual values for these items?

I've done the same in my environment, and it is working.

Screen Shot 2022-12-23 at 12.40.39 PM.pngScreen Shot 2022-12-23 at 12.42.58 PM.png

Ashbal December 23, 2022

Here are my real values

pr1 = RLP
pr2 = PCSUP

1. Here you can see RLP-87409 is linked to a PCSUP ticket 

image.png

2. But when I run this query , I am supposed to see RLP-87409 in the results because it is linked to a PCSUP ticket but I get 0 results

image.png

Trudy Claspill
Community Champion
December 23, 2022

What if you remove the "key in" clause and have just the issueFunction clause? Does RLP-87409 appear in the results?

Ashbal December 23, 2022

I removed "key in" and get nothing 

I also tried issueFunction in linkedIssuesOf("project = PCSUP")

with and without space between project and PCSUP

image.pngimage.png

Should I add anything else in the subquery to get data ? 

Trudy Claspill
Community Champion
December 29, 2022

Are the projects Company Managed projects or Team Managed projects?

Is just one type of link used or multiple types of links? I see in your first image that the "pr-1" issue has a "clones" link to the "pr-2" issue. Is Clones the only link type used between the issues you expect to see in the results?

I have tried to recreate this with the Clones link using issues in two Company Managed projects, and in two Team Managed projects, and have not been able to recreate the issue.

At this point I would recommend that you engage Atlassian Support or Adaptavist ScriptRunner support to investigate more.

Ashbal December 29, 2022

Both pr1 and pr2 projects are company managed

Some pr1 tickets are linked to pr2 project via "clones" 

Some pr1 tickets are linked to pr2 project via "relates to"

Here is something that I found (these are real project values) 

If I run this search, I get results 

project = RLP and issueFunction in linkedIssuesOf("project = PCSUP and status != done")

But If I run 

project = RLP and issueFunction in linkedIssuesOf("project = PCSUP") , I get no results 

So, I need to add an "and" clause inside linkedIssuesOf to get any result, but, I dont want to put any clause other than project inside "LinkedOfIssues"

Trudy Claspill
Community Champion
December 29, 2022

That is really odd. I don't have to do that.

I think Adaptavist Support might be your best help at this point.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events