Forums

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

Get the initial status of a Jira workflow

Andreas Dahlberg August 13, 2018

Hi

The jira rest-api for workflows is quite bad and as far as I can see there is no way to get the initial status (i.e the status that the issue is in after it is created) of an issue. By using the script runner it is possible to extend the rest-api. So my question is, how can I write a groovy script that returns the initial status of the workflow of a given issue?

 

 

1 answer

0 votes
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.
August 13, 2018

You can, but I don't see much point, as I can't think of a use for knowing the status new issues will go into.

Andreas Dahlberg August 13, 2018

Well, I can get the information of the different statuses in a workflow in Jira and their transitions by running:

https://<jira-url>/rest/projectconfig/1/workflow?workflowName=<workflow-name>

but this doesn't say anything about which state that is the initial state. If you know how to get the initial state, would you mind telling me?

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.
August 13, 2018

You can't, without code in Jira to expose it.  It's not there because it's of no use to you.

Jeff Abbott October 21, 2020

How can you do this with code? I need to interpret a workflow during a post function and need to know which status is the originating state w/o hard coding to the name.  Can I assume it is always the status with an incoming action/transition ID=1?

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.
October 21, 2020

That's a very different thing from knowing what the starting status in the workflow is.

At your point in the process, you've got an existing issue and are in the middle of a transition, so there is a step, and hence status, behind you.

In fact, the issue is still in the "previous" status until the "change status" post function executes, so if you put your post-function before it and use issue.getStatus() you should be able to get the "previous" status directly.

Jeff Abbott October 21, 2020

I have checked a dozen different workflows on my system. The action ID=1 is always assigned to the transition to the initial status, which in my case is "Create", but that name can be changed. The transition however is read-only and cannot be deleted, so I'm pretty sure it that is how the initial status is found. 

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.
October 21, 2020

Ok, but that has nothing to do with what you asked.

You're right, of course, action 1 is the transition from <nothing there> to "initial status", but not only can you change the name of that step, you can change it to point elsewhere.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events