jQuery to filter only when labels have multiple values

Vimali
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!
December 9, 2024

I need jQuery to get the list of bugs which has more than 1 label 

1 answer

2 votes
Harshit Grover
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.
December 9, 2024

Hi @Vimali ,

In Jira Cloud, to retrieve issues with more than one label using jQuery, you can make use of Jira's REST API. The basic approach involves:

  1. Making an API call to search for issues.
  2. Filtering the results based on the number of labels.

Here’s how you can do this with jQuery:

 

$(document).ready(function () {
const jiraUrl = "https://your-domain.atlassian.net/rest/api/3/search";
const username = "your-email@example.com";
const apiToken = "your-api-token";

const jql = "issuetype = Bug AND labels is not EMPTY"; // Jira Query Language (JQL)

$.ajax({
url: jiraUrl,
method: "GET",
headers: {
"Authorization": "Basic " + btoa(username + ":" + apiToken),
"Accept": "application/json"
},
data: {
jql: jql,
fields: "labels"
},
success: function (response) {
const issues = response.issues.filter(issue => issue.fields.labels.length > 1);
console.log("Bugs with more than 1 label:", issues);
},
error: function (error) {
console.error("Error fetching issues:", error);
}
});
});

 

Regards, 
Harshit

Vimali
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!
December 9, 2024

Thanks.

Is it possible to write just a jql to get the list of bugs with more than 1 label. labels is not supporting operators 

Suggest an answer

Log in or Sign up to answer