How to use Jira-Keys in Confluence (User) Macros

This example uses a new Template in Confluence and will utilize the following Addons.

Step-by-step guide

StepProcedure

1. Create an new Template in Confluence

  1. Insert the macro you want to use e.g. Insight Objects
  2. Configure the macro to your likings
  3. Save the template
  4. Open the template again in edit mode, to enable the source editor
  5. Open the source editor with the <> icon in the upper right corner
  6. Select the macro source starting with <ac:structured-macro and ending with </ac:structured-macro>

2. Open in a second browser tab User Macros under Confluence administration

  1. Create a new user macro
  2. Configure the macro to your likings
  3. Set under the Definition of User Macro the option to Rendered
  4. Exchange the source with the one from the Macro Base further down this page
  5. Replace the ## Exchange me from the Macro Base with the source from Step 1.f
  6. Likely you'll have a line like <ac:parameter ac:name="iql">key in (XYZ-1)</ac:parameter>
    • Replace the IQL e.g. key in (XYZ-1) with $body
  7. Save your macro

3. Back to the template

  1. Close the editor and reload the page
  2. If present remove the original insight macro
  3. Add the new user macro to the page
  4. Add in the macro your IQL while replacing the value with an confluence variable 


Macro Base
## Macro title: Dynamic Insight Objects
## Macro has a body: Y
## Body processing: Rendered
## Output: Insight Object Data
## Developed by: ---
## Date created: 2019-02-22
## Installed by: --- ---
## @noparams
#set ($body = $body.replaceAll("\Q&lt;p&gt;\E",""))
#set ($body = $body.replaceAll("\Q&lt;/p&gt;\E",""))
#set ($body = $body.trim())

<p>
## Exchange me
</p>

Take care to hit cancel in the source editor.

Save will break the confluence variables which wont work anymore with Issue to Page