JQL for searching value of one field equals value of another field

Esther Strom_ ACP-JA June 30, 2017

We need to run a search via JQL that will allow us to find issues where the value of the assignee field is equal to the value of the developer field. Obviously assignee = developer doesn't work; it tries to find any issues where the assignee field is set to the word developer. (Developer is a custom field.)

I found this answer which says that ScriptRunner can do it like this:

issuefunction in expression("project = FOO", "assignee = developer")

But a later question with an answer by the same person indicates that the ScriptRunner function will only work if the custom field is a date, datetime or numeric field.

Will the plugin work on a single user picker field, as indicated in the first post? If not, is there any other way to do this? It's something that SQL can do natively, and seems really unusual that Jira would not allow us to do that kind of search with JQL.

1 answer

0 votes
Ignacio Pulgar
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.
July 2, 2017

The documentation of the expression function contains a section named conversions which states:

Users

A String containing the user key. This is sufficient as they are just used for equality comparisons

So, I'd say Script Runner supports username equality comparisons.

Esther Strom July 6, 2017

Call me an idiot, but that sounds like my sample expression above should work. But it gives me an error: 

Token ("=" at 1:10: "=" ) is not allowed

 1:10 is, I'm guessing, first line, 10th position, which is the equals sign.

 

I also tried changing it to a double equals, and got this error:

java.lang.IllegalArgumentException: Unhandled custom field: customfield_11200

 

So I have to assume it's not supported the way you think it is. Note that I'm not trying to create my own JQL functions; I'm just looking to put this directly into a search.

 

WAIT.  "A String containing the user key." Does that mean that I need to search for specific values? Like, issuefunction in expression("project = PH", "assignee == estrom")? That's exactly what I said I'm NOT trying to do. I don't KNOW the user names. What I'm trying to do is find ANY ticket where the person in the assignee field, whoever they are, is also the person in the developer field. 

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events