Automatically add an issue of a certain type to an epic

You can use this script in a ScriptRunner Custom Post Function on the Create step to automatically fill in the Epic Link field at issue creation depending on the issue type. You can specify what issue type you want to check against and what epic you want to link to at the top of the script.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor // when you create an issue of issue type Story that will be under an Epic final String issueTypeName = "Story" // the issue key of the Epic final String epicIssueKey = "EPIC-1" if ( != issueTypeName) { return } def epicLinkCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName("Epic Link") def newEpic = ComponentAccessor.issueManager.getIssueByCurrentKey(epicIssueKey) issue.setCustomFieldValue(epicLinkCustomField, newEpic)
Discovered an issue? Report it here

Suggested for you