Good day,
I am trying to find a way to move automatically the issue type of all the subtasks while moving parent issue type.
Lets say we have a "Task" issue with a subtask "Task-subtask" and then we move the parent issue to "Bug" and I want subtask to automatically change to "Bug-subtask"
I am trying to add the following code in the additional issue action under the Fast-track transition an issue Listener which listens to the parent issue type move (this listener works well and changes the status of the parent issue):
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTasks = issue.getSubTaskObjects()
subTasks.each {
def newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.projectObject).find{it.name=="Bug- Sub-Task"}
if (newIssueType) issue.setIssueTypeObject(newIssueType)}
with the condition like this:
def types = ['Bug']
issue.issueType.name in types
But it fails 
I tried to add this code as postfunction on the parentissue transition but then it changes the issue type of parent issue to Bug-subtask
I am all new to Scriptrunner. Trying to figure our what might be the case here. Will be happy to hear any advices, thanks in advance