Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Products
  • Jira
  • Questions
  • How to use simple scripted validator for a particular project (in a shared workflow) and fix version field to be mandatory

How to use simple scripted validator for a particular project (in a shared workflow) and fix version field to be mandatory

Ganga Bopaiah February 15, 2017

I have to make the Fixed version mandatory for a project with key "AN". I add the following script in the simple scripted validator:

issue.projectObject.key == 'AN' && (null in issue.fixVersions*.name)

This workflow is shared with 60 projects, i want this just for the AN project. Right now irrespective of the fix version being empty or not, the error message shows up. I don't want the error if the user enters the value in the fix versions field

This is affecting all the projects which isn't the requirement

Regards

Ganga

2 answers

1 accepted

1 vote
Answer accepted
Tarun Sapra
Community Champion
February 15, 2017

Since issue.getFixVersion() returns a collection thus to check for null or empty simply fetching the value should be enough in groovy

thus, try this

if(issue.projectObject.key == 'AN') {
   if(issue.getFixVersions()) {
     return true;
  }
     return false;
}
return true;
Tarun Sapra
Community Champion
February 15, 2017

Or in a single statement

!(issue.projectObject.key == 'AN' && !issue.getFixVersions())

 

 

Tarun Sapra
Community Champion
February 15, 2017

You are getting the error for all projects as your condition is not right because you are checking the project name, in case there is any other project apart from "AN" then your statement will return false and thus the validation will fail.

0 votes
Ganga Bopaiah February 15, 2017

Let me try this and check

Tarun Sapra
Community Champion
March 19, 2017

Did my answer fix the problem?, if yes, please upvote/accept the answer. thanks.

Suggest an answer

Log in or Sign up to answer