Automatically link Parent to the epic on transition

John River September 25, 2019

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 

1 answer

0 votes
fran garcia gomera
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.
September 25, 2019

last line parentIssue shouldn't be sourceIssue?

Shawn Danisa September 27, 2019

Let me try it out. Thanks

Shawn Danisa September 27, 2019

Sorry, No. The variable name declared is ParentIssue.

Suggest an answer

Log in or Sign up to answer