Trigger Clones an issue, and links scriptrunner once.

Patrik Ytterström January 14, 2019

I need to be able to create issues in different projects when on a certain event.
Now I tried to trigger a clone when issue is updated and the component is set to "flytta".
The problem I get is that everytime I update the issue it creates a new clone.
I want scriptrunner to create the issue once when I added the component.
How to solve what event I should choose from when I want to trigger the action ?scriptrunner.PNG

1 answer

1 accepted

0 votes
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2019

Hello @Patrik Ytterström

You can use the Script Listener provided by the plugin 

"Clones an issue, and links"

The condition you have to enter is that you have to check if the update is on the component field or not.

Thus, this should work

def field = event.getChangeLog().getRelated('ChildChangeItem').any{ it.field.toString().equalsIgnoreCase("Component")}
if(field) {
return true;
}
return false;

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2019

In the above code you check whether the issue updated event is for the component or not and if it is then in the if statement above you can add your original statement which checks if the current component contains flytta or not.

Patrik Ytterström January 14, 2019

Thanks :), there is only one problem and that is if I want to add one more component the condition will be true as long as "flytta" is there.
I want the condition to listen only when a certain component is added, not if it "contains" the value. I will try to build on your code but would appreciate help.

 

def field = event.getChangeLog().getRelated('ChildChangeItem').any{ it.field.toString().equalsIgnoreCase("Component")}
if(field) {
if(issue.components*.name.contains('flytta')){
return true;
}
return false;
}
Patrik Ytterström January 15, 2019

I modified your script and got to this and it looks like it works as it should.



def field = event.getChangeLog().getRelated('ChildChangeItem').any{ it.field.toString().equalsIgnoreCase("Component")}

if(field){
def cField = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "Component"}

if(cField.newstring == "flyttar"){

return true
}
else{
return false
}
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2019

Hello @Patrik Ytterström

Glad to know that it's working now, please accept/upvote answer so that others are helped as well. thanks!

Suggest an answer

Log in or Sign up to answer