Behaviours plugin 0.5.10 compatibility with JIRA 6.1.7


I have a duplicate search that is generated when users enter a string into the Subject and Description fields during issue creation. The script takes the string and displays 10 similar tickets under the field to prevent duplicate tickets being created.

I can add the code if required, but my question is has JIRA 6.1.7 changed something with the way fields are treated so that you cannot script responses from text fields?

There are no errors generated so it appears that our upgrade from JIRA 6.0.3 to 6.1.7 has broken this functionality.


2 answers

0 votes

This question is a bit too fuzzy to answer.  You ask about plugin compatibility in the title (answered at ), but then start talking about a script which tries to do something with fields.  It doesn't matter if JIRA has changed "something with the way fields are treated" (which, in the broadest sense, it has not, so that's a complete red-herring), because that, well, um, works.

What has broken is your script.  Not the upgrade.

What I'm heading to here is yes - show us the code, because the problem is somewhere in that.

Hi Nic, I've added extra info, but as another answer rather than a response to your asking for more info so you may not have received the notification that this has been updated. Does the extra info give you any clues as to what is preventing my script from running after the upgrade to 6.1.7? Any help would be appreciated. Cheers, Jordan

Is there any way to gain visibility for my question here?

Very fair call and cheers for the response. I was trying to keep it simple but can see it was a bit all over the place.

I'll add the code below and how it is set up to provide a more clear definition of my issue.

The script below searches 2 projects (kid and sid) for similar issues to that being created. It was working in JIRA 6.0.3 and generating errors when invalid characters were entered into the summary etc but now JIRA does not register any reference to my script at all in the logs nor display duplicates as it did in 6.0.3 (albeit with 0.5.6 of the plugin with that version of JIRA).

It is implemented via the behaviours plugin admin interface as below:

Field: Summary
Optional (Require) 
Writable (Readonly) 
Shown (Hide) 

Validator Class: /data/jira/scripts/AutoDupes.groovy
Validator Method: getPossibleDupes
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.jql.builder.JqlClauseBuilder
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.jql.builder.JqlOrderByBuilder
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.query.Query
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
public class AutoDupes extends FieldBehaviours {
    // todo hrm... other languages
    def Set stopWords = new HashSet(["a", "an", "and", "are", "as", "at", "be", "but", "by",
        "for", "if", "in", "into", "is", "it",
        "no", "not", "of", "on", "or", "such",
        "that", "the", "their", "then", "there", "these",
        "they", "this", "to", "was", "will", "with"
        JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder()
        ComponentManager componentManager = ComponentManager.getInstance()
        SearchProvider searchProvider = componentManager.getSearchProvider()
        ApplicationUser appUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
        User user = appUser.getDirectoryUser()
    private int MAX_RESULTS = 15
    public void getPossibleDupes() {
        FormField frmSummary = getFieldById(getFieldChanged())
        Long pid = getFieldById("pid").getFormValue() as Long
                Long iid = getFieldById("id").getFormValue() as Long
                Long kid = 10061 as Long
                Long sid = 10001 as Long
                if (!pid) {
                        if (!iid) {
                                // Oh no!
                        } else {
                                IssueManager issueMgr = ComponentManager.getInstance().getIssueManager()
                                issue = issueMgr.getIssueObject(iid)
                                pid = issue.projectId
        StringBuffer sb = new StringBuffer()
        def String summary = frmSummary.getFormValue() as String
        if (summary) {
            if (pid != sid) {
                query = builder
            } else {
                query = builder
            SearchResults searchResults =, user, new PagerFilter(MAX_RESULTS))
            Collection issues = searchResults.getIssues()
            if (issues) {
                sb << "<div class=\"warningBox\">The following potential duplicates were found. Please look through them before submitting a new issue.<br><br>\n"
                issues.each {Issue issue ->
                    String highlightSummary = highlightMatches(summary, issue.getSummary())
                    sb << "<a href=\"../browse/${issue.getKey()}\" target=\"_blank\">${issue.getKey()}</a> - $highlightSummary<br>"
                // todo: replace/append original help text
                sb << "</div>"
        // choose one of the two methods of returning feedback to the user
        // comment the following line if using overlays
        // or
        // uncomment the following 3 lines for overlays
        // if (sb.length()) {
        //     frmSummary.setOverlay(sb.toString())
        // }
    public String highlightMatches(String searchTerm, String match) {
        searchTerm.split(/\s/).each {
            if (it && ! stopWords.contains(it)) {
                match = match.replaceAll(/$it/, "<em>$it</em>")

Thanks again,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,439 views 15 19
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