How to get listener to only 'fire once'

Hi Everyone,

I have created a listner using the ScriptRunner clone issues and links listner template. It is to create linked issues in different projects dependant on tick boxes in a multi tick list selectd during a transition.

The 'Event' it is set to is 'issue updated' and condition is

'Investment Report' in cfValues['RM Post Meeting Work Required Checkbox']*.value

Which does the job, but the probelm I have is that it is firing every time the issue is updated creating multiple linked issues. How can I tell the listner not to duplicate if the linked issue already exists. I have tried narrowing the Event from issue updated to custom field updated or custome field entered, but this doesnt create the linked issue.

Thanks very much.

1 answer

It could be enough to extend the condition, right? I would use something like this:

issueLinkManager.getInwardLinks(issue.getId()).isEmpty() && issueLinkManager.getOutwardLinks(issue.getId()).isEmpty()

thankyou very much that appears to have worked perfectly... I have been banging my head against a wall trying to get that to work. Thanks so much

Ahh, I thought I had it but im not quite there on further testing.. its possible that one issue could have multiple linked issues if more than one option is selected in the check box - so just verifying that there are no issues there isnt quite enough. I just cant the last tweak right. I need it to look at the tick box to see if the option has been selected, and if it has to look at the existing linked issues to see if there is already an issue that contains the option name in the summary. But that it will still allow parrallel listners to create issues if other options are selected in the checkbox.

I have tried to alter slightly to:

'Document 1' in cfValues['Multi Choice CheckBox']*.value
AndAlso issueLinkManager.getInwardLinks(issue.getId()).Notcontain'Document1' && issueLinkManager.getOutwardLinks(issue.getId()).Notcontain'Document1' 

Methods getInwardLinks and getOutwardLinks return IssueLink object. You can bet destination or source issue using issuelink.getDestinationObject() or issuelink.getSourceObject(). Then getSummary() method will give you summary value for comparison.

But I'm not sure if it will be easy to use these methods in the condition because you need to use some foreach cycle in it...

thanks v much, just giving that a go. You are right.. it is tricky

You can always implement script on issue transition but it is little complicated...you'd have to implement issue creation, issues linking etc...

Thanks, I think that is a bit complex for me at this stage. Still getting around the basics of writing script. I have spent most of the morning trying to get the getSourceObject alternative to work. I am resolved to just inserting aprompt for the users to create a new issue if a certain custom field is selected and rely on it being done manually. 

Appreceate your help.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

535 views 3 11
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