Transition Work Items

With HAPI, you can move work items through their workflow by triggering transitions. This page walks you through transitioning work items using HAPI’s Issues.transition function.

Pattern for transitioning work items with HAPI

When you transition a work item with HAPI, you can follow this basic pattern:

  • Import Issues from @scriptrunnerhq/hapi/issues.
  • Call Issues.transition inside your script’s default async function.
  • Provide:
    • The work item key.
    • The transition name (as configured in your Jira workflow).
  • Optionally provide a fields object to update fields as part of the transition (for example, setting a resolution). 

The following example shows this general pattern:

typescript
import * as Issues from '@scriptrunnerhq/hapi/issues' export default async function () { // Perform a simple workflow transition by name await Issues.transition('WORKITEM_KEY', 'Start Progress') // Or, perform a transition and update fields at the same time: // await Issues.transition('WORKITEM_KEY', 'Resolve Issue', { // fields: { // resolution: { name: 'Done' }, // // You can set other fields here if required by the transition // }, // }) }

You can use the same Issues.transition pattern to move a work item between workflow states by name, or satisfy transition requirements by setting fields (such as resolution) in the same call.

In-app script example scripts

The following examples are available in-app:

  • Transition a work item: Shows how to call Issues.transition with a work item key and a transition name (for example, "Start Progress") to move a work item to the next workflow state.

  • Transition a work item with field updates: Shows how to execute a transition (for example, "Resolve Issue") and simultaneously update fields such as resolution by passing a fields object as the third argument to Issues.transition.

On this page