How can I block a story epic link by a CF in epic?
This validation needs to be in issue creation
for examplean 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.ComponentAccessorimport com.opensymphony.workflow.InvalidInputExceptiondef issueManager = ComponentAccessor.issueManagerdef epicLink = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")def epic = issue.getCustomFieldValue(epicLink) as Stringif(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
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}
It looks like you're new here. Sign in or register to get started.