Add Label Macro

The Add Label macro adds specified labels to a page if they are not already present. Some predefined variables are allowed, and you can overwrite these variables or add specified custom variables.

This macro cannot be edited, but you can disable it. 

If you disable it in the instance, users will not be able to use the macro when working with Confluence pages in the instance.

Video walkthrough

Watch our video to see the Add Label macro in action.

Using the Add Label macro on a Confluence page

When you are editing or creating a page in Confluence, you can use ScriptRunner for Confluence to add a label to the page.

  1. Select Insert, and then select Other Macros.

  2. Select the Add Label macro from the provided list.

  3. Add the labels you want on the page to the Labels field.

    Labels must obey naming restrictions imposed by Atlassian. Certain characters (:, ;, ., ,, ?, &, [, ], (, ), #, ^, *, @, !, ', `, spaces) are not allowed.

    When possible, some restricted characters are modified to allow the successful application of labels.

    Use Provided Variables as Labels: ScriptRunner provides several variables that you can use to add specific labels. To use them, add the variables to the Labels field as you would any standard label.

    • $username - Username of the person who created and/or edited the page.

    • $fullname - The full name of the person who created and/or edited the page.

    • $year - The year when the page was created and/or edited.

    • $month - The month when the page was created and/or edited.

    • $day - The day when the page was created and/or edited.

    • $parent - The parent title of the current page.

    Once you save the macro and the page loads, variable labels load with the correct data. The added labels can be seen on the bottom right of the page.

  4. Click Insert and the label module appears on the page when the page is in edit mode.

  5. Save the Confluence page.

Result

When the page where the macro is located is saved or refreshed, the labels are applied. If some of the labels are already present, only the missing labels are applied. If all the labels are already present, no action is taken.

On this page