cloning and updating epic link

sajsyed January 13, 2016

Hi 

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 .

 

Thanks,

Syed

 

 

 

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2016

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.
if(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 4.1.3.4.

I hope this helps.

Thanks

Kristian

Ovidiu Vasilescu March 25, 2018

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.

 

Thanks,

Ovidiu.

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 10, 2018

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.

Thanks

Kristian

Suggest an answer

Log in or Sign up to answer