[JIRA] Wanna replace this JWT boolean condition with Adaptavist?

I’m not an ambassador for Adaptavist, but just blogging this piece just in case if anyone finds interesting.

In some JIRA workflow configurations you might let certain statuses to allow any status transition inbound. This effectively allows a “transition loop”, making it possible to transition to itself. In UI/UX perspective, this wastes screen space for an additional transition button.

For example, when current status of a given issue is “In Progress”, you don’t want to see a transition button called “In Progress” on that screen.

One solution that JIRA admins use is the boolean condition included in JIRA Workflow Toolbox plugin. The trick is to name workflow transitions exactly as their target status name, and the following one-line code works like a charm.

%{00176}!=%{00016}

Loosely translated to English:

%{Current transition}!=%{Issue status}

If you want to use Adaptavist’s Script Runner (which is one of my favourite JIRA plugins so far) instead of JWT (JIRA Workflow Toolbox), here’s the source code for a a custom script condition (not “simple script”).

import com.atlassian.jira.component.ComponentAccessor

def workflowManager = ComponentAccessor.workflowManager
def workflow = workflowManager.getWorkflow(issue)
def actionId = transientVars['actionId']
def currentAction = workflow.allActions.find { a ->
    a.id == actionId
}

if(issue.status.name.equals(currentAction.name)){
    passesCondition = false
}else{
    passesCondition = true
}

Bit of a work, but you can copy-paste it and it works.

[JIRA] Wanna replace this JWT boolean condition with Adaptavist?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s