How to correctly check for status change in a Script Runner listener condition.

I am a newbe so please be kind.

I have workflow that is firing an "Issue Updated" event on a transition to "In Development". (I have had problems with the other events being heard by the listener and would in fact prefer to use another).

I want to create a linked issue in a different project via the listener but to only do this on transition and not upon editing the issue in any other way.

After much testing it appears as though my syntax and understanding of the condition in the listener is not correct as it is never "true". The current condition is set as follows.

(issue.status?.name == 'In Development') && (issue.status?.name != originalIssue?.status.name)

I suspect that the problem lies with the "originalIssue?.status name" as the linked issue is created when testing the first half of the condition issue.status?.name == 'In Development". Maybe originalIssue.status is not available at this execution point, if so how do I achieve what i need to do?

Please also explain what the difference is between issue.status?.name and issue.status.name - what is the significance of the question mark (I am very new to this syntax/language).

Is this the best way to do this?

1 answer

1 accepted

Have you considered creating the linked issue directly from the source issue's workflow's post-functions for that transition. This would eliminate the need to check status names as you can be sure of when the post-function will fire. There is a ScriptRunner post-function that handles this scenario very well.

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,175 views 6 19
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
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