It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner - Identify Cloned Issues via Listener

hello Community,

Is there a way to have a listener trigger when an issue is cloned.

I do not see issue clone as one of the Events you can associate to a listener.

I am aware that a "CLONE" triggers a "CREATE", would there be a way to check the issue on create for a specific attribute that signifies that it was cloned as opposed to created?

Any help is much appreciated!

-Roberto

1 answer

1 vote

You are correct that you can only listen for CREATE event.

And I think that if your cloning process doesn't include either a summary prefix or clonners linked issue type, then there might not be anything in the event that will identify this as a clone.

Basically, if you can't tell from looking at any attribute of the issue that it was a clone rather than fresh ticket, then there is no way to know in the listener.

Hi @Peter-Dave Sheehan ,

The cloned issue has the issue linked of "cloned by" that JIRA appends.

This is my code for trying to pick up when something is cloned: 

Issue issue = event.issue
UserManager userManager = ComponentAccessor.getComponent(UserManager)

def clonedIssues = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())?.findAll {it.issueLinkType.outward == "Cloners"};

if (clonedIssues) {
//Do all the processing I need to do since this is a cloned issue
}

 Utilizing the above code I still cant seem to target only the issues that are created through clone as opposed to just naturally created.

Do you see anything faulty in code or is there a different way to asses?

The prefix of "clone" is not reliable since users can replace it before they initiate clone.

Thanks for the help!

-Roberto

IssueLinkType have 3 main attributes: name, outward description and inward description.

Looks like you were looking at the value of the outward description and comparing it to the string that matches the name.

Try either:

def clonedIssues = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())?.findAll {it.issueLinkType.name == "Cloners"}

or

def clonedIssues = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())?.findAll {it.issueLinkType.outward == "clones"}

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

947 views 8 25
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you