Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Duplicate values custom field


Looking for some general advice and pointing in the right direction!

Tools: Jira, Scriptrunner , JSU

Field: Artefact ID (single line text type)

Problem: We want to prevent users entering duplicate values on this field on a transition screen. Ideally we would show a error message telling the user it is a duplicate value. And if possible link this ticket to the duplicate when they enter a unique Artefact ID.

So I believe we would need to do some validation using SQL on the database for this custom field values. Is that possible using groovy/scriptrunner?

Hoping to avoid installing/purchasing any other plugins and do this with scriptrunner

Any help much appreciated


2 answers

HI @Richard Duffy ,

Do you resolved is request?

I have the same  request .

I try to use this script but i dont have success result.

if you have some idea please tell me



HI Andrey


No we decided to simplify our business process, best of luck!

Thanks for you response ,

Thanks for you response ,

I have resolved the request 



Like Richard Duffy likes this


Did you manage to script this? If so can you share with us?



Yes  i share my script :


import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.component.ComponentAccessor

def parser = ComponentAccessor.getComponent(JqlQueryParser)
def query = parser.parseQuery("project = ${issue.projectObject.key} and 'Wallet Address' = ${cfValues['Wallet Address'].value}")

def searcher = ComponentAccessor.getComponent(SearchService)
def kount = searcher.searchCountOverrideSecurity(currentUser, query)

return kount == 0


My custom field is Wallet Address 

0 votes

Hi Richard,

What you need is a scripted validator that would run a JQL search and if that returns any results then show an error to the user. The logic is as follows:

1. User enters some artefact id on a transition screen

2. A JQL search is ran with the following query: "Artefact ID = ${artefact id from screen}"

3. Assuming all artefact ids are unique if that search returns any results then the user is trying to submit already existing id

4. Show an error message with the ticket with the same id

The code for such validator is as follows:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query
import com.opensymphony.workflow.InvalidInputException

Issue issue = issue
CustomField artefactId = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Artefact ID")
String artefactIdValue = issue.getCustomFieldValue(artefactId)
String jql = "\"Artefact ID\" ~ ${artefactIdValue}"
List<MutableIssue> jqlIssues = getIssuesFromJQL(jql)

if (jqlIssues) {
throw new InvalidInputException("Artefact ID already exists in issues: ${jqlIssues}")
return true

List<MutableIssue> getIssuesFromJQL(String jqlQuery) {
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
Query query = jqlQueryParser.parseQuery(jqlQuery)
SearchResults searchResults =, query, PagerFilter.getUnlimitedFilter())
List<MutableIssue> mutableIssueList = searchResults.getIssues().collect { issue -> issueManager.getIssueObject(issue.getId()) }
return mutableIssueList

Hi Ivan

Thanks for the reply. This looks very promising.

Let me start with a quick question?

Q. Should I use a "custom script validator" or "simple script validator" and what is the difference between the two options?

I have tried the custom script validator, it does give some errors/warnings

Script Errors & Warnings.PNG


No effect on the workflow transition screen when entering a duplicate

*** Note ***

my field (Artefact ID) - Select list is "Free Text Searcher"

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events