Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,370,118
Community Members
 
Community Events
168
Community Groups

Scriptrunner Script Listener not working on Workflow Transition

I use an Scriptrunner Script Listener to create sub-tasks. My script condition is as follows:

def subtaskIssueTypes = issue.getSubTaskObjects().collect {it.getIssueType().getName()}
(cfValues['Purge Stock']?.getValue() == 'Yes') && (!('Purge Parts' in subtaskIssueTypes))

So the condition above should return TRUE when the Purge Stock custom field value equals "Yes" AND when there is NOT already a Purge Parts sub-task created.

The Script Listener event is set to Issue Create and Issue Update. The Script Listener does NOT work when I change the custom field value to "Yes" on a workflow transition screen. However, it DOES work when I set the value to "Yes" on the issue CREATE screen and when changing the custom field value to "Yes" from the VIEW screen.

Any ideas why the transition screen isn't working?

4 answers

@Alexey Matveev _Appfire_

I tried adding the Generic Event along with the Issue Update event. When I did this, it caused the two sub-tasks to be created instead of one. So the good news is that the Generic Event did cause the sub-task to create on issue transition. But the problem is that it seems that the Issue Create and Generic Event each created a sub-task. Strange.

0 votes

Hello,

The problem is that when you change a field on a transition screen the Generic event fires by default. I guess, that is your case. Add Generic event to your listener.

Have a look at the Create issue transition. What event do you throw there? Try to log the event name in the listener and have a look what happened.

log.error(ComponentAccessor.getEventTypeManager().getEventType(event.getEventTypeId()).getName())

0 votes

Hello @Gavin Minnis

This is happens because during the transition invokes event that specified in this transition and it seems it is not ISSUE_UPDATED event.

So the easy way to resolve this is - fire some custom event on transition and catch it with listener.

And the hard way learn more about event bundles.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events