You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Auto Link and Issue to an Epic


A Post-Function to automatically link an issue type (for example a Story) to a specific Epic when the issue is being created. This will take effect only if the Epic Link field in that issue is left blank.


In the sample code below, an issue type is automatically linked to an Epic if the Epic Link is not added when the issue is being created.


  • Jira Jira (8.0 - 8.18)
  • ScriptRunner for Jira ScriptRunner for Jira (6.32.0)
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.type.EventDispatchOption def customFieldManager = ComponentAccessor.customFieldManager def issueManager = ComponentAccessor.issueManager def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser //This requires name of the Issue Type that is to be linked to the Epic final def issueTypeName = '' //This requires key of the Epic that will be linked the issues final def epicIssueKey = '' def epic = issueManager.getIssueByCurrentKey(epicIssueKey) def epicLinkCustomField = customFieldManager.getCustomFieldObjects(issue).findByName('Epic Link') if ( != issueTypeName) { return } if (!epicLinkCustomField.getValue(issue)) { issue.setCustomFieldValue(epicLinkCustomField, epic) issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false) }
Discovered an issue? Report it here

Suggested for you