Default Label Values
Introduction
Some groovy knowledge required. With the introduction of the new version of Label Tools for ScriptRunner Confluence, we allow users the ability to specify the default label values for the Choose label macro.
This could be useful in a scenario where new choose label macros are created frequently with the same list of labels. This removes the need to edit the macro and repetitively add the labels to each macro.
Note
|
The Choose label macro on any given page can still be edited and specific labels can be added in the label field, however this means that the default labels will no longer be displayed on this specific macro. |
Note
|
If default label changes are not reflected in the macro then it might be necessary to disable and enable the macro again in the Script Macros section in Confluence Administration. |
Instructions
This example will extend the "Choose Label" macro.
-
Navigate to your script root. Default is <Confluence>/home/scripts. More information about script roots.
-
Create the package com.onresolve.scriptrunner.canned.confluence.macros in your script root.
-
Navigate to the package specified above and inside the macros folder create a new groovy class "ChooseLabelMacroModified.groovy" that extends the old class and overrides the getDefaultLabels method. A descriptive class name is recommended.
-
Populate the class:
package com.onresolve.scriptrunner.canned.confluence.macros
class ChooseLabelMacroModified extends ChooseLabelMacro {
@Override
String getDefaultLabels() {
return "engineering, sales, support, hr"
}
}
-
Disable the old macro in the Script Macros section in Confluence Administration. Enable the new macro in the same section. The names of the macros will be the same as to not break any macros already used.
-
Use the Choose label macro on a page. Notice that it will have 4 options in the dropdown list as default, engineering, sales, support and hr.
Macro class names that support default values
-
ChooseLabelMacro
For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.
Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.