Transition an Issue using Issue Input Parameters


Utilise input parameters while transitioning an issue. This example modifies parameters and validates transitions for each sub-task for a specified issue.


I'm a product manager. I want to create sub-tasks of a parent issue with the same characteristics when I move the parent issue to the 'In Progress' state. With this post function, all sub-tasks of a parent issue will get the same value as the parent issue automatically when the parent issue transitions to the 'In progress' state.

Good to know

  • Use this script as a post function associated with the In Progress step.
  • Sub-tasks must be created before transitioning the parent issue to the "In Progress" state


Jira Jira (8.0 - 8.14)

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser import java.text.SimpleDateFormat // the step you want sub-tasks to be transitioned to final actionName = 'In Progress' // the name of the 'Date' custom field final startCustomFieldName = 'Projected Start' // the name of the 'User Picker (single user)' custom field final projectManagerCustomFieldName = 'Project Manager' def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issueService = ComponentAccessor.issueService def customFieldManager = ComponentAccessor.customFieldManager def workflowManager = ComponentAccessor.workflowManager def simpleDateFormat = new SimpleDateFormat('dd/MMM/yy') def projectedStartCustomField = customFieldManager.getCustomFieldObjects(issue).findByName(startCustomFieldName) assert projectedStartCustomField: "Could not find custom field with name $startCustomFieldName" def projectManagerCustomField = customFieldManager.getCustomFieldObjects(issue).findByName(projectManagerCustomFieldName) assert projectManagerCustomField: "Could not find custom field with name $projectManagerCustomFieldName" def workflowActionId = workflowManager.getWorkflow(issue).allActions.findByName(actionName)?.id issue.subTaskObjects.each { subtask -> def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.setSkipScreenCheck(true) issueInputParameters.setResolutionId(issue.resolutionId) issueInputParameters.setSummary(issue.summary) issueInputParameters.setDescription(issue.description) issueInputParameters.setAssigneeId(issue.assigneeId) // copy the value of the 'Projected Start' custom field from the parent issue def projectedStartCustomFieldValue = simpleDateFormat.format(issue.getCustomFieldValue(projectedStartCustomField)) issueInputParameters.addCustomFieldValue(, projectedStartCustomFieldValue) // copy the value of the 'Project Manager' custom field from the parent issue def projectManagerCustomFieldValue = issue.getCustomFieldValue(projectManagerCustomField) as ApplicationUser issueInputParameters.addCustomFieldValue(, projectManagerCustomFieldValue?.key) def transitionValidationResult = issueService.validateTransition(currentUser,, workflowActionId, issueInputParameters) assert transitionValidationResult.isValid(): transitionValidationResult.errorCollection def transitionResult = issueService.transition(currentUser, transitionValidationResult) assert transitionResult.isValid(): transitionResult.errorCollection }
Discovered an issue? Report it here

Suggested for you