Forums

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

Validator to match Summary with a Custom field

Prabakaran P September 22, 2022

Hi All, 

I'd like to set up a validator that acts like if the summary matches with a single select custom field values it should warn the user and should throw the error. 

I'm looking for a scriptrunner validator to do the job. 

The single select custom field has about 500+ values. 

If the user creates an issue with anyone of the value name as a summary it should warn the user. 

Is there any possibility with Scriptrunner/other Validators? 

 

Thanks!

Prabhu

1 answer

0 votes
Florian Bonniec
Community Champion
September 23, 2022

Hi @Prabakaran P 

SO you want to block the user if the value of the summary is an option available in a customfield or do you want to check with the selected value only ?

 

If it's the first, I don' t really see the use case but the code below should work or help at least.

Use Simple Scripted Validator and replace XXXXX with your customfield id

import com.atlassian.jira.component.ComponentAccessor

def customfieldManager = ComponentAccessor.getCustomFieldManager()

def optionsManager = ComponentAccessor.optionsManager

def customfield = customfieldManager.getCustomFieldObject('customfield_XXXXX')

def fieldConfig = customField.getRelevantConfig(issue)

List<String> options = optionsManager.getOptions(fieldConfig).stream().collect{it.getValue()}

return !options.contains(issue.summary)
Prabakaran P September 29, 2022

Hi @Florian Bonniec  Thanks! 

I just want to warn the users, hey, you selected the same values as XYZ field contains!! that's it. 

Suggest an answer

Log in or Sign up to answer