Simple scripted validator - Version Picker (multiple versions) value validation

I need help with throwing an error when a value of custom multi select list (Version Picker (multiple versions) ) is 'Value1' and fixversions is empty.

I tried:

!(cfValues["Multiselect"]*.value.contains ("Value1")) || issue.fixVersions

!('Value1' in cfValues['Multiselect']*.value) || issue.fixVersions

But the validation of the custom field always returns error for any values, even without the second part.

 

1 answer

Hi Vitalia,

As an alternative you can get the versions in a Version Picker like this:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Version Multi Picker"}
def versionsList = issue.getCustomFieldValue(tgtField)

The values in the list are not strings but versions therefore in order to get the name you should call the getName(), so in your case in order to check if a version with name 'Value 1' exists in the list

return versionsList?.find {it.getName() == 'Value 1'} ? true : false

The issue.fixVersions part is ok. Hope that helps.

Kind regards

Thanos

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

147 views 1 17
Join discussion

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