script listener not cloning with two conditions; when "all projects" selected as source

running a script listener - clones an issue and links

when i select a single project for source, event - issue created

  1. for one condition  cfValues['testcf1'].value == 'opt1', this works fine, it creates a clone in target project and links
  2. for two condition - cfValues['testcf1'].value == 'opt1' && issue.Labels()*.label == 'test' , this is not working

Also for 1, one condition, if i select "All Projects" as source, since i want clone any project issue with that custom field, scriptrunner is creating multiple issues continuously, i have to cancel the operation.

@Jamie Echlin [Adaptavist], can you please check this and help us.

i want clone an issue from any project, when both conditions are met, how can we achieve this with scriptrunner.

thanks

 

 

3 answers

1 accepted

So, one easy way to address the infinite issue creation would be to add a third clause to your condition that prevents cloned issues from being included. You could either specify the project & issue type that the target issue will be, then exclude that specific project/issue type combination in your condition.

Another way would be to use the Additional issue actions script block to set a field on the target issue, then exclude issues with that field set to that value. For example:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
issue.setCustomFieldValue(customFieldManager.getCustomFieldObjectByName("My Custom Field"), "DO NOT CLONE THIS")

Then, your condition might be

"test" in issue.labels*.label & cfValues['testcf1'].value == 'opt1' && cfValues["My Custom Field"] != "DO NOT CLONE THIS"

Your comment above is right, and should resolve the labels not being considered.

for 2 conditions below code works good.

"test" in issue.labels*.label & cfValues['testcf1'].value == 'opt1'.

but still when i select "All projects" as source, it keeps cloning issues!!!!

Jonny, Thanks for your response, i am selecting target project and issue type for above event listener.

Problem is when i select source as "All Projects" infinite issue creation happens. when i select single  project as source, this works fine.

i want to clone an issue from any project when condition is met to target project.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,156 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot