Add cloned issue as Epic Link on transition



I'm trying to do a nifty Epic Workflow which creates some tasks / stories on certain transitions. I want these Tasks to have Epic link the original issue they were cloned from. Note that they are cloned from the Epic itself, so they can't inherit the Epic Link of the issue they were cloned from since Epics don't have Epic Link.

I've tried a few things so far and this one I was expecting to work, any ideas why it isn't?

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'Epic Link'}
issue.setCustomFieldValue(cf, sourceIssue.key)




2 answers

1 accepted

0 votes
Answer accepted

I tried a very dirty & basic workaround which solved a problem for me in the past:

  1. Create "Dummy" field
  2. On Epic creation, copy field Key to field "Dummy"
  3. On Epic transition, clone issue as Task
  4. On Task creation (inside the Task workflow), copy field "Dummy" to field "Epic Link"


I'm getting this error when looking at the Epic after I do this, so setting the field Epic Link requires something specific which I don't know about. The issue Key is not good enough.


EDIT: This actually works, just be careful to set the Copy Field to Field post-function AFTER the issue is created.

Tarun Sapra Community Champion Aug 08, 2016

"I'm getting this error when looking at the Epic after I do this" - Do you mean Task or Epic?

Tarun Sapra Community Champion Aug 08, 2016

"This will exit the Creation process and leave an inconsistency on issues. Make sure the "Creates the issue originally." Post Function is first in the Create transition."

Right, that was a bit embarrassing. Well I'm happy to say that with this dirty workaround (and having the "Copy link from "Dummy" to "Epic Link"" AFTER the issue was created) it works.

And it gracefully fails for other situations (such as when someone creates one manually).

Tarun Sapra Community Champion Aug 08, 2016

nice to hear, could you please accept or upvote my answer. thanks.


1 vote
Tarun Sapra Community Champion Aug 08, 2016

Please see here -

issue.setCustomField might not be right

Tarun Sapra Community Champion Aug 08, 2016

the same thing here - (answer by  user Dima Pasko )


Also, make sure that you have "Epic Link" issue added on the "Screens" of the issueTypes which are being cloned.

Epic Link is added on the Screen, that's not the problem.

Even though the first ticket wasn't about a post-function, it had a snippet of code that might be what I was looking for. I tried it and it didn't work:

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def tgtField = customFieldManager.getCustomFieldObjects(issue).find { == "Epic Link"}
def changeHolder = new DefaultIssueChangeHolder();
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), sourceIssue.key),changeHolder);

My coding skills are really not that strong and I'm really out of my league right now. I really don't understand why issue.setcustomfield = sourceissue.key doesn't work.

Epic Link is a custom field and it's expecting an issue key, so it should work, no?


Any help is appreciated.

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 ...

400 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