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)

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.


I also tried to apply this on the scriptrunner listener but it doesn't work. 

I copied kate lines to "Clones an issue, and links" additional. can you please explain how you did it?

Did you Define the Custom field manager first?

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

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

What am i doing wrong?

clonning without sprint.PNG

Kate, can you help me please?

0 votes

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
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

441 views 8 26
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