It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I add labels to a Jira through javascript? Edited

I am trying to make a google extension that will add labels when you click one button. It is also supposed to add a subtask as well. I am stuck at the point where I do not know how to get the labels to be applied to the page.

JSON:

{ 
"name":"Jira Extension",
"version":"1.0",
"description":"Allow for quick access to changing SD and TA",
"permissions":[
"activeTab"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"background":{
"persistents": false,
"scripts": ["background.js"]
},
"options_page":"options.html",
"manifest_version":2
}

 HTML:

<input id="scYes" class="submit" type="submit" name="scyes" value="SC Yes">
<input id="scNo" class="submit" type="submit" name="scno" value="SC Yes">

Javascript&colon;

window.onload = function(){
document.getElementById('scYes').onclick = function(){
var label = '{ "labels" :["Sd_reviewed", "Ta-reviewed", "Reviewed", "Functional"] }';
var myObj = JSON.parse(label);
document.getElementById("demo").innerHTML = myObj.labels;
};
document.getElementById('scNo').onclick = function(){
var test = '{ "labels" :["Reviewed", "Technical"] }';
var myObj = JSON.parse(test);
document.getElementById("demo").innerHTML = myObj.labels;
};
}

The scYes is simply a button to confirm that the user would like to add the labels. I am not very experience with Json or Javascript 

1 answer

Hi @Devi Foskett , did you figure this out?

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you