Exclude fields from being copied when clonning an issue using groovy script


I'm using script runner 'Clones an issue and links' to clone an issue.

How can I exclude cusotme fields and non custome fields from being cloned?

What is the syntax to use in the "Additional issue actions" box?


4 answers

if field is custom
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'CustomFieldName'}
issue.setCustomFieldValue(cf, null)

1 vote

You need to just null out the fields you don't want to copy, eg

issue.assignee = null


It seems Sprint cannot be nulled out?

I would think it can... What code did you use?

Jamie, did you ever determine if this was actually possible?

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'}
issue.setCustomFieldValue(cf, null);

Yes... just zero out any field you don't want copied.

Thanks Kate - I ended up doing exactly that.

0 vote

The clone in groovy effectively calls most of the internal Jira clone function, which really does just copy everything.

To clone an issue with fields being dropped, you'll need to write your own script that can pull data from an existing issue and use bits of it to create a new issue.

I'm not sure this is the case, not as I remember it anyway.

Clone Plus Plugin for JIRA provides options for customizing clone operations including field excludes. This provides issue actions (not workflow functions) that can help with some team work flows that don't need to be associated with a issue transition.

Create on Transition Plugin for JIRA does provide workflow functions for creating issues and subtasks with control over which fields get copied to the new issue. Not exactly cloning but with most of the same capability.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

268 views 0 6
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