Forums

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

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

vs
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 25, 2015

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

0 votes
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 26, 2015

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
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events