Setting an issue status to Closed via API

Jeanne Dixon August 17, 2016

I have been able to create issues through vba/vb.net 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 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2016

Nope.

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.

Jeanne Dixon August 17, 2016

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2016

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.

Jeanne Dixon August 18, 2016

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).

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 18, 2016

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 Sign up to answer