Found AutoDupes.groovy script to detect duplicate issues, but only works when creating issues not editing


I came across this script while looking for a free alternative to Suggestimate and it works perfectly when creating new issues (shows the top matches for the Summary field to help reduce duplicate tickets) however I'm getting errors in the log and no results returned when editing an issue.

Probably should note that it relies on the Behaviours plugin to function.

The script that I found from, all credit to Jamie Echlin who originally "grooved" it up.

My question, I am not quite a groovy programmer, but was hoping it would be a simple fix to have it work both when creating issues as well as editing them. What is null when editing an issue that is not null when creating an issue? Something to do with clauseValues if that helps.

The error in the logs:

2012-09-06 13:22:42,135 http-8443-85 ERROR username 802x88429x1 1msl8i1 ###.###.###.###,###.###.###.### /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Something went wrong with  method getPossibleDupes in class /data/jira/scripts/AutoDupes.groovy

com.atlassian.jira.util.dbc.Assertions$NullArgumentException: clauseValues should not be null!

        at com.atlassian.jira.util.dbc.Assertions.notNull(

        at com.atlassian.jira.util.dbc.Assertions.containsNoNulls(

        at com.atlassian.jira.jql.builder.DefaultJqlClauseBuilder.addNumberCondition(

        at com.atlassian.jira.jql.builder.DefaultJqlClauseBuilder.addNumberCondition(

        at com.atlassian.jira.jql.builder.DefaultJqlClauseBuilder.project(

3 answers

1 accepted


I think the pid (project ID) is null when editing (not tested though).

Try inserting the following directly under this line: "Long pid = getFieldById("pid").getFormValue() as Long" (line 27).

if (!pid) {
            pid =

The whole thing is here:

Hey Jamie,

First of all cheers for such a quick reply! Also the script you wrote is brilliant, thank you for having that out there as well!

I tried adding the code above (and verified I had inserted it into the correct spot by checking with the script you referred to, but unforutnately am getting the following error:

[onresolve.jira.groovy.BehaviourManagerImpl] Something went wrong with method getPossibleDupes in class /data/jira/scripts/AutoDupes.groovy

java.lang.NullPointerException: Cannot get property 'projectObject' on null object

To confirm it was the project Id that was null I added the snippet below (in place of and results came up as expected.

pid = 10001

I tried various snippets of code that I found via google to determine the project Id to no avail.

I should add that I am running JIRA 4.4.5 if that changes anything?

Thanks again for the help so far,



No worries. What version of the behaviours plugin do you have? There was an issue whereby getUnderlyingIssue() was not always working in previous versions.

What you need to do is, if the pid is null, get the issue id:


Then use IssueManager to get the issue, and from that get the pid.

So can you confirm anyway that the pid is null when editing an issue, and that the id is not null?

Thank you very much Jamie, I got it going!

Added the following code to your script:

import com.atlassian.jira.issue.IssueManager


Long iid = getFieldById("id").getFormValue() as Long

if (!pid) {

if (!iid) {

// Oh no!

} else {

IssueManager issueMgr = ComponentManager.getInstance().getIssueManager()

issue = issueMgr.getIssueObject(iid)

pid = issue.projectId



Thanks again for your guidance, and in answer to your question:

The pid is null when editing an issue, as when I manually set the pid the script worked when editing the issue (I entered pid = 10001).

The issue id is not null, else my "// Oh no!" would have come into play during my testing.

Cheers again,


No problem Jordan, good work...

For you other question, I'm using v0.5.0 of the Behaviours plugin.

Cheers again,


I had one more question about this script, I've had a good go at writing this myself but cannot get my head around adding an orderby clause to the query.

I would like to sort by project as I've customised this script to search the current project plus a repository project with precedence given to results from the repository.

It appears to be similar to this:
ordered = query.orderBy().project(ASC).endOrderBy().buildOrderBy()
and I'm importing this:
import com.atlassian.jira.jql.builder.JqlOrderByBuilder

The error:

2012-12-05 15:29:28,312 http-8080-5 ERROR jordan 929x4496x1 mc4v7a /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Something went wrong with method getPossibleDupes in class /data/jira/scripts/AutoDupes.groovy

groovy.lang.MissingMethodException: No signature of method: com.atlassian.query.QueryImpl.orderBy() is applicable for argument types: () values: []

Possible solutions: every(), every(groovy.lang.Closure), grep()

I'm happy to open a new thread too but as it relates to this script thought it best post here.

Any help would be appreciated,


It would be best to open a new question... it relates to the script but is not about the script. Simply because you're going to get more views in a new question. I don't see getOrderBy() in

Cheers Jamie, will do. Thanks as always,


hi @Jamie

can i use the auto dupes to monitor some customfield value instead of sumarry field ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


280 views 0 7
Read article

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