---
title: "Exposing transition names based on a given issue status (using Groovy)"
canonical: "https://support.appfire.com/space/SUPPORT/523174234/Exposing%20transition%20names%20based%20on%20a%20given%20issue%20status%20(using%20Groovy)"
format: markdown
---
Many use cases from our customers involve working with issue status(es). However, there might be particular scenarios where a customer might be required to retrieve a <u>**transition name(s)**</u> (*based on an issue's current/previous status).*

## \uD83D\uDCD8 Instructions

Depending on the customer's use case, **two possible scenarios** can be considered:

1. Things get pretty straightforward if the customer would like to get a <u>**currently executed transition name**</u>. You can freely use the `getCurrentTransition().get().name` method + property to get the transition name.

> ℹ️ **Limitation**: the `getCurrentTransition()` method (hence the `getCurrentTransition().get().name` property) only works when used as part of a workflow configuration. **This method will not retrieve any data when used as part of an Event-based action.**


2. The customer wants to retrieve the <u>**transition names associated with the previous and current status**</u>. In this case, a Groovy script that uses some of the standard Jira classes can be used. The code snippet below that can be used for this purpose.

> ℹ️ **Limitation**: as this proposed solution is based on statutes, the returned results won't be unique (meaning a single value) if multiple transitions can lead to the same status.
> ℹ️ 
> ℹ️ <u>*Additional note below from our L3/dev team:*</u>
> ℹ️ 
> ℹ️ *Suppose multiple transitions lead to a specific status. In that case, there's no easy way to know which one has been executed: Jira stores that information only in the internal OS_HISTORYSTEP database table, which has no public API.*

```
import com.opensymphony.workflow.loader.ActionDescriptor
import com.opensymphony.workflow.loader.StepDescriptor

def workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue)
def workflowStatuses = workflow.getLinkedStatusObjects()
def currentStatus
def prevStatus
prevStatus = workflowStatuses.find{item -> item.name == issue.getFieldHistory("status").fromString.last()}
currentStatus = workflowStatuses.find{item -> item.name  == issue.getFieldHistory("status").toString.last()}

StepDescriptor stepDescriptor1 = workflow.getLinkedStep(prevStatus)
StepDescriptor stepDescriptor2 = workflow.getLinkedStep(currentStatus)
```

As an example of this second scenario, the capture below shows the output for the script when used as part of an *Email Issue* post-function ([https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461767713](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461767713)) configuration (*Html Body* section).

![image](media://7b1fc001-eeca-483b-9db4-9ad150859062)

## \uD83D\uDCCB Related articles



> Macro (contentbylabel)