Get JQL or valid Filter ID from Jira default Filters

Hi,

Is it possible to get the list of Jira default filters using the rest API?
I’m trying to get the JQL or the filter ID, but on the URL parameter there is only available a filter “-1” that doesn’t exist.

Thank you,
Paulo Alves.

Hi Paulo,

I just do this:

                if (externalFilterId < 0) {
                    switch(externalFilterId) {
                        case -1: // My open issues
                            jql = 'assignee = currentUser() AND resolution = Unresolved';
                            break;
                        case -2: // Reported by me
                            jql = 'reporter = currentUser()';
                            break;
                        case -3: // Viewed recently
                            jql = 'issuekey in issueHistory()';
                            break;
                        case -4: // All issues
                            jql = '';
                            break;
                        case -5: // Open issues
                            jql = 'resolution = Unresolved';
                            break;
                        case -6: // Created recently
                            jql = 'created >= -1w';
                            break;
                        case -7: // Resolved recently
                            jql = 'resolutiondate >= -1w';
                            break;
                        case -8: // Updated recently
                            jql = 'updated >= -1w';
                            break;
                        case -9: // Done issues
                            jql = 'statusCategory = Done';
                            break;
                        default:
                            AP.flag.create({
                                title: 'Unsupported predefined filter',
                                body: 'Filter ' + externalFilterId + ' is not known',
                                type: 'error'
                            });
                            return;
                    }
1 Like

Hi Andriy,

Thank you for the suggestion! :slightly_smiling_face:

I’m trying to get this information from the Rest API to avoid issues with changes from Atlassian. May be they will add, remove or update these filters and we will lose the compliance.

If the API doesn’t provide this data, probably I will implement a solution similar to the one you presented.

Regards,
Paulo Alves.

Hi @paulo.alves, at this moment there is no straightforward way to get the IDs of default filters through Jira Cloud REST API. And we do not plan to extend Jira Cloud REST API in that way anytime soon, so it looks like you’d be better off following the suggestion from @azhdanov.

Cheers,
Eve

2 Likes

Hi Eve,

Thank you for the response!

Cheers,
Paulo Alves.