Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,297,828
Community Members
 
Community Events
165
Community Groups

JS Button to delete label and add label

Edited

Hello,

I have pages created with label "ESP". At some point I will want to archive the page. To do this I want to remove "ESP" and add "Archived". 

 

Below is code that allows a new label to be added OK through my testing, but the removal does not work.

 


<!DOCTYPE html> 
<html><head></head>
<body>

<button onclick="runScript()">Archive Project</button>
<p><div id="result"></div></p>

<script type="text/javascript">
function runScript() {

var archived = "archivedtest";
AJS.Labels.addLabel(archived, AJS.params.pageId, AJS.params.contentType);

var current = "esp";
var labels = $(".aui-label-split-main");  
  if( labels[i].innerHTML.search(current) == esp ) {
        AJS.Labels.removeLabel( $(labels[i]), AJS.params.pageId, AJS.params.contentType);
}

};

</script>

</body></html>

Please can someone advise on what is wrong with the code and how I can remove "ESP" label? 

 

Thanks!

1 answer

0 votes
Brant Schroeder Community Leader Jan 09, 2022

@JONATHAN RUSSELL welcome to the Atlassian community 

If you are truely archiving the page I would recommend leaving the labels.  The page will be the archive section that most will not be able to access.  You may also want those labels if you restore it.  You might consider only adding a label if you want it but I would think you would want to retain the old labels for true archival purposes.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

89 views 0 0
Read article

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