Forums

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

JQL: is it possible to sort status by Status category

Tatiana Marti October 9, 2023

Hello,

In certain JQL searches, we would like an order by status category, or even, if possible, by order of workflow status.

Do you know if this is possible?

Thanks a lot.

Tania

3 answers

1 accepted

2 votes
Answer accepted
Ste Wright
Community Champion
October 9, 2023

Hi @Tatiana Marti 

It's not possible to order by status category unfortunately.

You can order by Status order though - the order is based on the order of Statuses within your system (i.e Jira Administration > Issues > Statuses)

ASC is classed as top > bottom of list.

Ste

Tatiana Marti October 13, 2023

hello,

It was very painful to classify the 68 statuses manually and one by one but it works

Thanks a lot

Tania

Like Ste Wright likes this
Sven Koch
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!
March 17, 2025

Reordering 237 statuses wouldn't have been feasible manually. I therefore created this user script, which will oder them "To Do" < "In Progress" < "Done":

https://gist.github.com/SVNKoch/90a76c8e265267b8b23a7f954bc82c24

 

// ==UserScript==
// @name         Jira Reorder Statuses in Admin Page by StatusCategory
// @namespace    jira.violentmonkey.userscript
// @match        https://jira.*.com/secure/admin/ViewStatuses.jspa*
// @version      1.0
// @description  Orders entries by status: "To Do" < "In Progress" < "Done"
// @grant        none
// ==/UserScript==

(function() {
    "use strict";

    var slowMode = false; // will highlight each line to be reordered, scroll to it and wait shortly before reordering

    const toDo = "To Do";
    const inProgress = "In Progress";
    const done = "Done";

    function moveStatusUp(status) {
        var rows = document.querySelectorAll("tbody tr");
        for (var i = 1; i < rows.length; i++) {
            var currentStatusCell = rows[i].querySelector("td.overflow-ellipsis span[data-tooltip*='jira-issue-status-tooltip-title']");
            var previousStatusCell = rows[i - 1].querySelector("td.overflow-ellipsis span[data-tooltip*='jira-issue-status-tooltip-title']");
            if (!currentStatusCell || !previousStatusCell) continue;
            var currText = currentStatusCell.getAttribute("data-tooltip") || "";
            var prevText = previousStatusCell.getAttribute("data-tooltip") || "";
            if (status === toDo) {
                if (currText.includes(toDo) && !prevText.includes(toDo)) {
                    var link = rows[i].querySelector("a[href*='StatusUp.jspa']");
                    if (link) {
                        if (slowMode) {
                            rows[i].style.backgroundColor = "yellow";
                            rows[i].scrollIntoView({behavior:"smooth", block:"center"});
                            setTimeout(function(){ window.location.href = link.href; }, 1000);
                        } else {
                            window.location.href = link.href;
                        }
                        return true;
                    }
                }
            } else if (status === inProgress) {
                if (currText.includes(inProgress) && prevText.includes(done)) {
                    var link2 = rows[i].querySelector("a[href*='StatusUp.jspa']");
                    if (link2) {
                        if (slowMode) {
                            rows[i].style.backgroundColor = "yellow";
                            rows[i].scrollIntoView({behavior:"smooth", block:"center"});
                            setTimeout(function(){ window.location.href = link2.href; }, 1000);
                        } else {
                            window.location.href = link2.href;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    function moveStatusesUp() {
        if (moveStatusUp(toDo)) return;
        if (moveStatusUp(inProgress)) return;
    }

    window.addEventListener("load", moveStatusesUp);
})();

It will take some time to run, as each "click" refreshes the page, but it was waaay faster then doing it manually.

 

Update: found another script that might be helpful here: 
https://jaus.atlassian.net/wiki/spaces/JAUS/pages/33452/Reorder+Status

1 vote
Hannes Obweger - JXL for Jira
Atlassian Partner
October 9, 2023

@Tatiana Marti (cc @Ste Wright),

perhaps I'm missing something, but wouldn't

ORDER BY statusCategory

do exactly that? 

EDIT: This appears to be supported in Jira Cloud only.

Bill Sheboy
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 9, 2023

Hi @Hannes Obweger - JXL for Jira 

I am using Jira Cloud, and that worked for me also.  But Tatiana appears to be using Jira Server: did you try it with that version?  Thanks!

Kind regards,
Bill

Like Robert Kalweit likes this
Ste Wright
Community Champion
October 9, 2023

To be clear, I tried it on Server - it doesn't work.

Ste

Like # people like this
Hannes Obweger - JXL for Jira
Atlassian Partner
October 9, 2023

Yep, confirmed; thx @Ste Wright. TIL.

Like # people like this
1 vote
Asha Goyal
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 9, 2023

Hi @Tatiana Marti

Status category values can be used in JQL queries and formulas.You can create a custom JQL search using Status or Status Category for use in Reports and filters.

You can use below query for status category 

project= "XYZ" AND statusCategory = Done

The order by will first order by statuscategory, then if two issues have the same statuscategory, Jira will order by status.

Thanks 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events