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

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

932 views 5 18
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot