The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
PD 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 Champions.
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