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

scripted validator code

Jamie Cole October 11, 2017

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

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Jenna Davis
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.
October 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

TAGS
AUG Leaders

Atlassian Community Events