Update Macro
You can use this script to update macro parameters in bulk. This script updates every selected parameter of the selected macro in pages found by the CQL query.
For more information on performance, check out Update Macro Performance.
Different ways to run Update Macro
You can use the script in several different ways by using combinations of the fields. The following three sections guide you through using the script in different ways:
Use Parameter and Value Fields
Use the Code Transform Field
Use Parameter, Value, and Code Transform Fields
Examples
Make Table of Contents consistent
Using the built-in Confluence macro Table of Contents, you can organize page content and skip directly to the information you're looking for. You can use the Update Macro built-in script to make the table of contents (TOCs) consistent across the Confluence instance.
In this example of the Update Macro script, we update the Maximum Heading Level to for all TOC macros in a specific space. The Maximum Heading Level number is used to limit the headings displayed within the table of contents. For example, 2 will list headings up to h2.
Once you run the script, all TOCs in the Confluence instances will contain heading levels 1 and 2.
Update Code Snippets with a New Version
Using the Mibex Software's Include Bitbucket for Confluence macro, you can provide a branch or tag name from a linked Bitbucket repository to display a specific version of a file.
We use the Include Bitbucket for Confluence macro to display code snippets in our documentation. In this example of the Update Macro script, we replace the tag parameters in pages found by the CQL query containing the Include Bitbucket for Confluence macro to 6.16.0.
Once you run the script, all code snippets from the linked repository are updated.
Update Markdown Macro with a New Body or URL Using the Code Transform Field
Using ScriptRunner's Markdown macro, you can insert your own markdown inline tags or render them from a URL. Typically, you would want to include markdown from a Gist or a repository in Github or BitBucket.
In this example, we change your Markdown macro's URL to point to a new path but we do not completely replace the current parameter. We also update the body of the macro to something new. By using a few lines of code within the Code Transform field of Update Macro, you accomplish both of these goals.
Once you run the script, all markdown in the selected pages are updated.