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

Hi,

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?

Thanks.

4 answers

This widget could not be displayed.
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)

This widget could not be displayed.

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

issue.assignee = null

etc

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.

Hi,

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?

This widget could not be displayed.

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.

This widget could not be displayed.

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 Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

492 views 3 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