Hi Team,
I have a request to add every "Task" issue assign to one specific epic link. I have used below code and working excepted, but currently when creating a new task, even if we assigned a different epic to a task, at the time of creation it automatically changes it and assigns mentioned epic the script (EPIC-1). we only want EPIC-1 assigned when the field it left blank during the ticket creation. Could you please suggest on this.
The original request of this requirement is : https://community.atlassian.com/t5/Jira-Software-questions/Default-epic-to-newly-created-tickets/qaq-p/1642030#M129927
Link : https://library.adaptavist.com/entity/automatically-add-epic-link-into-issue-of-certain-type
import com.atlassian.jira.component.ComponentAccessor
// When you create an issue of issue type Story that will be under an Epic
final issueTypeName = "Story"
// The issue key of the Epic
final epicIssueKey = "EPIC-1"
if (issue.issueType.name != issueTypeName) {
return
}
def epicLinkCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName("Epic Link")
def newEpic = ComponentAccessor.issueManager.getIssueByCurrentKey(epicIssueKey)
issue.setCustomFieldValue(epicLinkCustomField, newEpic)