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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,463,275
Community Members
 
Community Events
176
Community Groups

Restrict Fixversion to one value

Hi All,

I am testing a case where i would want to restrict the "Fix Version/s" field of JIRA to a single value.

Following is the screenshot from the behaviour configured but it is not working. Not sure why!

image2017-2-1 18:10:7.png

Any help is appreciated.

JIRA version : v7.2.7
Scriptrunner version : 4.3.16

Thank you in advance,
Parashar

3 answers

1 accepted

1 vote
Answer accepted

Following script did the job.

def fixVersionsField = getFieldById("fixVersions")
def fixversion = fixVersionsField.getValue() as Collection
if (fixversion.size() > 1) {
    fixVersionsField.setValid(false)
    fixVersionsField.setError("Fix Version/s can only be one value.")
}
else {
    fixVersionsField.setValid(true)
     fixVersionsField.clearError() 
}

Screenshot for reference.

image2017-2-17 12:49:39.png

-Parashar

This is not working for me at all.

I am using the same exact script code above ..

Any thoughts on where I can debug..

Jira Version: 7.1.10

Scriptrunner Version:  5.0.4

 

def fixVersionsField = getFieldById("fixVersions")
def fixversion = fixVersionsField.getValue() as Collection
if (fixversion.size() > 1) {
fixVersionsField.setValid(false)
fixVersionsField.setError("Fix Version/s can only be one value.")
}
else {
fixVersionsField.setValid(true)
fixVersionsField.clearError()
}

Single_FixVersion.JPG

I was able to solve this using a Scripted Validator in my workflow as follows:

 

import java.util.ArrayList;
import java.util.Collection;
import com.atlassian.jira.config.ConstantsManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.project.version.Version;
import com.opensymphony.workflow.InvalidInputException;
Collection <Version> fixVersions = new ArrayList<Version>();
fixVersions = issue.getFixVersions();
if(fixVersions.size() > 1)
invalidInputException = new InvalidInputException("fixVersions","Only 1 FixVersion allowed");

This script worked like a charm. Thanks, @Parashar Joshi 

The Script worked for me. Thanks Parashar Joshi

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events