I would like to automatically create an Epic, when it's parent is transitioned to In-Progress.
Some background: I've configured portfolio for jira to have an initiative issuetype as the parent to the epic. The goal is that when we transition the Initiative to In progress, an epic will be automatically created and linked to the Initiative.
What I've done:
- On the Initiative Workflow, In progress transition, I created a post function to clone issue and links with scriptrunner.
- Selected the target project: Project BEAN
- Selected the target issuetype: Epic
- Field to copy: None and added the following script:
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
UserMessageUtil.success('Reporting Epic, created successfully.')
issue.summary = 'Reporting: ' + sourceIssue.summary
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Issue Key'}
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(cf as String) // Parent issue key here
def parentLink = customFieldManager.getCustomFieldObjectByName("Parent Link")
parentLink.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(parentLink), parentIssue),new DefaultIssueChangeHolder())
The Epics are created in the correct project, however, the linking to the intiative is not working. Please advise