Custom Macros

You can use this feature to write your own static content macros.

Create a custom macro 

  1. Select the Settings cog in the top right-hand corner of the screen. 
  2. Select Macros under ScriptRunner
  3. Select Create Custom Macro.
  4. Fill out the fields that appear: 

    1. Macro Name: Enter a name to identify your macro for you and your users. 
    2. Description: Explain what your macro accomplishes.
    3. Enabled (radio button): Control if your macro can be made available to your users. 
    4. Body Type: Set the body type of the macro. 
      • Rich Text: The macro allows Rich Text content, which can be formatted, to be inserted.
      • Plain Text: The macro allows Plain Text, which is unformatted, to be inserted. 
      • None: No body. 

        Different Macro Editing Experiences

        Depending on what kind of Body Type you select for this field, your user will have a different editing experience. 

        • If you select Rich Text, your user can edit the body of the macro directly on the page. 
        • If you select Plain Text, your user is directed to a macro editor to enter their body of the macro.
        • If you select None, your user sees their macro without a body to edit

          This above image also shows how a macro set up with required parameters is displayed before parameter values are provided.

    5. Output Type: Choose how the macro appears on the screen.
      • Block: The macro will be on its own line on the Confluence page.
      • Inline: The macro will be inline with other content on the Confluence page. 
    6. Script to Execute: Enter the script for the macro here.
  5. Add any parameters you need for the macro's functionality by clicking Add Parameter

    1. For each parameter that you add, a modal appears where you fill out the following fields: 

      1. Type: Select the type of parameter you want. 
        • Attachment: Allows users to select an attachment from the page when editing the macro on the page. The filename of the attachment is passed to the macro.
        • Boolean: Allows users to add a checkbox field to the macro.
        • Confluence Content: Allows users to select a Confluence page or blog post when editing the macro on a page. The page name is passed to the macro.
        • Int: Allows users to pass a number to the macro when editing the macro on the page.
        • LabelAllows users to choose a label(s) when editing it on a page and have the selected label(s) passed to the macro.
        • SpacekeyAllows users to select one or more Confluence spaces when editing the macro on a page. The space key is passed to the macro.
        • String: Allows users to add a text input field to the macro. 
        • URLAllows users to enter a URL when editing the macro on a page.
        • UsernameAllows users to select user(s) when editing the macro on a page. A list of accountId(s) is passed to the macro.
      2. Name: The name of the macro parameter. This appears to you and the user.
      3. Description: The description of the macro parameters. This appears to you and the user.
      4. Required: If the parameter is required, tick the box. 
      5. Hidden: If you'd like the parameter to be hidden, tick the box.
      6. Multiple: You can add multiple values for certain parameter types, like enum

        You can select Actions and then Remove the Parameter () if it's no longer needed.

    2. Click Save
      The parameter you added now appears in a table: 
  6. Select Save

Result: The macro now shows up on the main macro screen, and you can use it the same as the built-in macros.