Get Workflow status in ScriptRunner using Behavior

Kumar Pappu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 4, 2022

Hi,

I have 3 tabs that I display and out of the 3 tabs, 2 tabs are disabled by default using the following script in Behavior.

disableTab(1)
disableTab(2) 

Now, I want to enable Tab 1 from the Behavior ScriptRunner only if the workflow status is "Ready".  Here is the below code:

import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.getIssueManager().getIssueObject(underlyingIssue.getKey())
if (issue.status.name == "Ready" ) {
switchTab(1)
disableTab(2)
} else {
disableTab(1)
disableTab(2)
}

The above code does not work.

Can anyone assist?

Thanks,

KP

 

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2022

"underlyingIssue" is an issue. So you don't need to convert it.

The problem is that on a create screen, underlyingIssue doesn't exist. But we can protect against that using the nullsafe operator (?)

So this should work:

if (underlyingIssue?.status?.name == "Ready" ) {
switchTab(1)
disableTab(2)
} else {
disableTab(1)
disableTab(2)
}
TAGS
AUG Leaders

Atlassian Community Events