cloning and updating epic link


Epic-1 -->task1–>Subtask1

in the above with the help of script runner, i am cloning the subtask1 and creating a new task task2 in one of the transitions.

For the task2 i want to set the epiclink as epic1.

Could anyone help me with the script in the subtask transition .







1 answer

Hi Syed,

You could use the Clones an Issue and Links post function provided by Script Runner with the code shown below in the additional issue actions box and the configuration shown in the screenshot below.

// Required Imports
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
// Get a reference to the Epic Link Field 
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');

// Get the Epic Issue so that the cloned issue is added to the Epic
Issue epic = ComponentAccessor.getIssueManager().getIssueObject("KDP-23")

// If the Epic issue is a valid issue then add the cloned issue to the epic.
issue.summary = 'Task 2' 
issue.setCustomFieldValue(epicLink, epic);  

image2016-1-25 13:14:6.png


As long as the epic issue object specified represents an Epic issue type then the cloned issue will be added to the epic.

This was configured using JIRA 6.4.12 and Script Runner

I hope this helps.



Hi Kristian,


A bit late to the party but I have the same requirement as OP.

Your solution may work in one case but doesn't that mean hardcoding the Epic inside the script? Is there a way to:

1. Use Clone an Issue and Links on Epic 1 Issue

2. Have it create Task 1

3. Have Task 1 be in Epic 1 with an Epic Link (using a script in the Clone an Issue and Links)


Hardcoding the Epic ID inside the script is not really a fair solution. This needs to scale and work on any Epic that does this transition.




Hi Ovidu,

My example above was a simple example of how to set an epic link.

The script could be modified to get all epics for a project if required and if you look at other answers on Atlassian Community then you should be able to find an example of how to do this.



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

247 views 6 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you