How can I block a story epic link by a CF in epic?
This validation needs to be in issue creation
for example
an issue type Story can only have a epic link if this epic has the custom field 1 = abc
Hi @Valeria Cruz,
Below script may give you some idea/reference. I haven't tried this my workflow though, it may require some minor changes
Try adding in Custom Script Validator in create transition
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def issueManager = ComponentAccessor.issueManager
def epicLink = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")
def epic = issue.getCustomFieldValue(epicLink) as String
if(epic){
def issueE = issueManager.getIssueObject(epic);
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Custom Field")
def cfValue = issueE.getCustomFieldValue(cf) as String
if(cfValue == "abc"){
return true
}
else{
throw new InvalidInputException("Invalid Epic Association")
}
}
BR,
Leo
Tks Leo, its working!!
but I need to validate the fields empty too. 'cause we can create story without a epic link too
I'm trying to use
else if(epic == null ){
return true
but doesn't worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, if you notice my script I already did a validation for epic is empty or not
if there is Epic it does enters for field validation if not. it won't.
I just missed to add Else part in the bottom. below may fix your issue
if(epic){
//code written already for field validation if epic mapped
}else{
return true // if issue created without epic
}
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.