I searched a lot, but nothing worked. There are downloadable Makros who manage to add labels you type into them, but as they´re not open source I can´t get behind that magic, which of course works, as I tested. Using the REST Api didn´t work, using the labelManager and labelUtil also lead to nothing. But I am sure there´s a way to use the labelManager to do so, maybe with the function "addLabel(Labelable content,
Label label)
" but there I don´t know with what to fill the parameters, beacause I have no access to the current page and I don´t know how to create a new label.
Thanks for your help
I've tried adding labels via user macro, and the easiest thing I've found is to use ajax and let Confluence take care of the rest of the details. Here is a simple user macro that adds a label based on what you type into a text field.
## @noparams <script> var addLabel = function(label) { jQuery.post(contextPath + "/json/addlabelactivity.action", {"entityIdString": "$content.id", "labelString": label, "atl_token": jQuery("#atlassian-token").attr("content") }, function() { jQuery("#label-to-add").val(""); }); } </script> <form class="aui" onsubmit="return false;"> <input id="label-to-add" class="text"> <button class="aui-button aui-button-subtle" onclick="addLabel(jQuery('#label-to-add').val());"> <span class="aui-icon aui-icon-small aui-iconfont-add">Add </span> </button> </form>
thank you very much it works fine for me :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is great! Thanks for posting.
Can I use a field in my macro example "Document Number" that populates the label for the page. I'm pretty new to this so I'm no sure how to do that yet.
I currently have my users populating a number of fields in a macro. I wanted to use the "Document Number" field to update the label of the page.
what should I add to do this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for this macro. It still works with Confluence 6.11.2.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.