cloning and updating epic link

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

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

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.

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

138 views 0 3
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