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?
I have posted a similar issue. Might be the same cause:
https://community.atlassian.com/t5/Jira-questions/Scriptrunner-Script-not-updating-native-fields-when-triggerd-by/qaq-p/1128707#M359308
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.