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

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'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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,636 views 8 2
Join discussion

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