It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automatically link Parent to the epic on transition

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

last line parentIssue shouldn't be sourceIssue?

Let me try it out. Thanks

Sorry, No. The variable name declared is ParentIssue.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

344 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you