Scriptrunner Script Listener not working on Workflow Transition

Gavin Minnis August 3, 2018

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

Suggest an answer

Log in or Sign up to answer
0 votes
Leonard Chew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2019
0 votes
Gavin Minnis August 4, 2018

@Alexey Matveev

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
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2018

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.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 4, 2018

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
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2018

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.

TAGS
AUG Leaders

Atlassian Community Events