scripted validator code

Upon creation I would like to make Epic link Mandatory if the fix version = a specific value only

1 answer

1 accepted

This widget could not be displayed.
Jenna Davis Community Champion Oct 16, 2017

Hello, 

Here's an example of a validator that should do what you're wanting:

import com.atlassian.jira.component.ComponentAccessor

def versions = issue.fixVersions

def epicLink = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")

if(versions[0].name as String == "Version 1.0" && versions.size() == 1){
log.debug("Epic Link: ${issue.getCustomFieldValue(epicLink)}")
if(issue.getCustomFieldValue(epicLink) != null){
return true
}
return false
}
else return false

This can be set up as a Simple Scripted Validator on the Create transition, which I believe is what you were wanting. My example script works when 'Fix Versions' is only 'Version 1.0'. It then checks that Epic Link has a value. You can modify the condition in the 'if' statement to make it work for you. 

Let me know if you have any problems or questions!

Jenna Davis

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

307 views 1 4
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