Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Make Epic Link a required field

Edward Greathouse August 30, 2018

Hi,

I'm trying to make Epic Link a required fields for all issue types except Epics. Here is what I have

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Level
import org.apache.log4j.Logger


def myLog = Logger.getLogger("com.onresolve.jira.groovy")
myLog.setLevel(Level.DEBUG)

// Get a reference to the Epic Link Field
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link')
def epicIssue = issue.getCustomFieldValue(epicLink) as Issue
def issueType = issue.getIssueType().getName()
myLog.debug("Issue type is " + issueType)
myLog.debug("Epic link is " + epicIssue)
// If the Epic issue is not an epic, then check if the epic link is set
if(issueType != 'Epic')
{
if(epicLink != null) {
myLog.debug("Epic Link is not set")
}
else {
return true
}
}
else {
return true
}


However, I am returned with the following even when I set the Epic Link field:

2018-08-30 15:53:16,320 DEBUG [jira.groovy]: Issue type is Bug
2018-08-30 15:53:16,320 DEBUG [jira.groovy]: Epic link is JIRA-35
2018-08-30 15:53:16,320 DEBUG [jira.groovy]: Epic Link is not set

 
Any ideas?

Thanks!

1 answer

0 votes
Mohamed Adel
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.
August 30, 2018

Could you please try to remove (!) from

if (epiclink !=null)

as this will always give you “not set” if the link exist  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events