Setting an issue status to Closed via API

I have been able to create issues through vba/ code. Now I need to be able to set the status to closed without progressing through the workflow. I have not seen a clear example of how to do that. Could someone provide an example of the code necessary to set the status to closed?

1 answer

0 vote


Because "Now I need to be able to set the status to closed without progressing through the workflow" is self contradictory.  To change the status of an issue, move it through the workflow.  That's the only safe way to do it.

Let me try to explain why we may need to set the status immediately to closed. We are using JIRA to track the progress of work generated within our material system that was developed in-house. In some cases people will generate a work order, but it may be a duplicate, contain incorrect information, etc. If they choose to cancel that work order, I need to close it within JIRA so it will no longer be tracked as an open item. In those cases I need to force the issue to closed when then cancel it in the material system.

The reason is perfectly valid, there's plenty of others for doing it too.

It's also irrelevant, you need to go through transitions to change the status. 

In this case, you just need to add a new transition from <somewhere> (possibly all status?) into Closed and then use it when you need it.  You can even call it "cancelled" and limit the resolutions to things like "duplicate, incorrect data, cancelled by user" etc.  But you need to do it via a transition.

OK. So please explain what "possibly all status" means and what I would need to code up to get it from where ever it is in the status to closed. I assume I would have to put in a loop to go from this status it is at to closed, but I don't have any idea how to go about setting that up and checking where it is in the loop (if that is the way to go).

The "possibly all" status is just saying that you might want to be able to instantly close an issue from any point in the process.  I don't know what your process is, so I can't tell you what status you might want to add the missing transistions from - one, many or all!

To make the workflow match your close process, you need to edit the workflow.  The minimal thing you need to do is create a new transition from the status (e.g. Open) you want to have the immediate close from, pointing to the "closed" status.

Save that change, and you'll be able to close issues from "Open".  If you want to use this step from other status, add more transitions, but, if it's the same process from the other status into closed, you don't need new transitions, you can select "reuse existing transition" instead.

If you want to close from all status in the process, then select "all status can go to this" when adding the transition.

Finally, have a look at the conditions and post-functions on the new transition(s).  If you want to limit this closing function to certain people, use conditions.  If you want to be clever about it, you can do extra processing in post-functions.  A good example is a "close as duplicate" transition.  Instead of asking the user to set a resolution, add a post function that always sets it to "duplicate" (and if you've got scripting, add a link to the duplicate as well!)

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,300 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot