Forums

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

How to access Status Category in groovy script

Nic Stransky June 6, 2017

I can get the status of an issue, but I can't figure out how to get the status category (To do, In Progress, Done).

Can someone please help?

Nic - if you're out there.

1 answer

1 accepted

3 votes
Answer accepted
Nic Brough -Adaptavist-
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.
June 6, 2017

If you've got the status, you're half-way there!

Given an issue, I've used

def sc = issue.getStatus().getStatusCategory()

You'll probably want to try

  • sc.getColorName()
  • sc.getAliases()
  • sc.getName()

and so-on for the actual data

Nic Stransky June 6, 2017

Thanks!!!!!  Man google was NO help on this one. Can't believe it hadn't been documented before anywhere.

Is there a primary reference for Groovy script methods? I found one page but it was really hard to search and navigate so I wasn't able to drill down to anything related to category.

Nic Brough -Adaptavist-
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.
June 6, 2017

It's not really Groovy doing this.  The "def" bit is Groovy, letting you create an untyped variable to work with later, but the rest is Java calls into the JIRA AP.

If you go to https://docs.atlassian.com/jira/server/ you'll see the java documentation for JIRA's API.

In the code, you've got an "issue" object, so go find the class for "issue" in the "all classes" panel and click on that.  The detail panel will show you the available methods  and what they return.  So getStatus() returns a Status object, so you click on that to see that object and then you'll see the getStatusCategory() call fetches a statusCategory and that has the three get methods I suggested trying!

I suspect Google was less help than usual because the getStatusCategory call is relatively new and may not have been widely posted yet.

 

Tomáš Vrabec
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.
September 20, 2019

@Nic Brough -Adaptavist- thanks for that even in 2019

Not sure if its funny or sad, but if you run

issue.getStatus().getStatusCategory().getName()

over an issue which is in Status which is "Done" Status Category you will get a string "Complete"  ¯\_(ツ)_/¯ 

Thanks man!

Like Nic Brough -Adaptavist- likes this
Nic Brough -Adaptavist-
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.
September 20, 2019

Yeah, that is really odd. As you say: ¯\_(ツ)_/¯ 

Uday Kiran Bhaviri March 23, 2022

We can use getTranslatedName() to get exact category i.e "Done" instead of "Complete"

issue.getStatus().getStatusCategory().getTranslatedName()

Suggest an answer

Log in or Sign up to answer