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

Can i add labels with the Javascript API for blueprint wizards?

Florian K. Sep 17, 2013


is it possible to add labels by the Javascript API for blueprint wizards? Exists a variable for the label identifier?

E.g. in the $container or wizard data properties, like this to edit the page title:

state.pageData.title = titleString;

Link to the Atlassian Docs:

Thank you



4 answers

1 accepted

7 votes
Answer accepted
Yagnesh Bhat May 21, 2014

The above answer by Ruth can be made even more easy by changing the title and name attribute to name="labelsString" title="labelsString", this will enable a REST call within confluence to add the labels programatically like magic! No need to write any java code if you do this small change - give it a try.

Ruth Kusterer May 22, 2014

Yagnesh Bhat, thanks, good tip! I removed the LabelManager code, and with name="labelsString" it works indeed. Ironically, I refactored the labelsString variable name for readbility, and that broke it. "title" seems to be another variable that we should not refactor.

But title="labelsString" is not needed, it only sets the tooltip in the wizard.

Atlassians, is this documented somewhere? My team keeps bumping into easy solutions like this by chance (for macros, for plugins, ...), after we spent a week trying to reinvent the wheel.

Andreas Mueller Feb 15, 2019 • edited

Yagnesh Bhat, thank you for your pointer. All I had to do was to add the following line in my dialog-wizard.js file: state.wizardData.labelsString = "new_label_to_add";


The complete (simplified) function looks like this:

Confluence.Blueprint.setWizard('a.b.c.plugins.confluence.knowledgebase.knowledgebase:create-kb-article-blueprint', function(wizard) {
    wizard.on('submit.page1Id', function(e, state) {
        state.wizardData.labelsString = "new_label_to_add";

1 vote
Ruth Kusterer May 04, 2014

Try the following for a LabelPicker.

In atlassian-plugin.xml add:


In your soy file, add:

<div class="field-group">
  <input id="my_article-labels" class="text select2-input long-field" 
      name="articleLabels" title="Search labels" type="text"

In your dialog-wizard.js add:

function postRender(e, state) {
  var wizardForm = state.$container;
  var labelsField = $("#my_article-labels", wizardForm);
      separator: " ",
      queryOpts: {
          spaceKey: state.wizardData.spaceKey

In BlueprintCreatedListener(LabelManager labelManager...)'s onPageCreateEvent() method, add:

Set<String> labelsList = new HashSet<String>();
labelsList.addAll(Arrays.asList((((String) context.get("articleLabels"))).split(",")));
for (String label : labelsList) {
    Label labelToAdd = new Label(label);
    labelManager.addLabel((Labelable) blueprintPage, labelToAdd);

The name="articleLabels" is your context variable that stores the labels.
The id="my_article-labels" is what connects the SOY input field to the JavaScript ui-component.

0 votes
Gavin Fowler Nov 04, 2013

I'm also looking for a solution to do this within my custom blueprint (as Atlassian have done with their Troubleshooting Article blueprint). Can I aks did you find a solution - is there any snippets you can share?

0 votes
Isaac Montes Mar 24, 2014

Need this too any suggestions

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

958 views 12 15
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