• 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

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
Accepted answer
Tarun Sapra Community Champion Feb 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 Feb 15, 2017

Or in a single statement

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

 

 

Tarun Sapra Community Champion Feb 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.

Let me try this and check

Tarun Sapra Community Champion Mar 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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,495 views 15 20
Read article

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