Example: Return the Page ID
You can create a macro to pull the Page ID of Confluence content onto a Confluence page.
This is a simple example of the way a custom macro can return page information. This example can be customized for different results.
Create the macro
- Select the Settings cog in the top right-hand corner of the screen.
- Select Macros under ScriptRunner.
- Select Create Custom Macro.
- Enter a Name to identify the Macro, like Page ID.
- Enter an optional Description, like Gets the page ID.
- Select Enabled to allow the macro to be added to pages.
- Select None for Body Type.
- Pick Block for Output Type.
Enter the following script into the Script to Execute field:
groovyreturn parameters.get("pageId")
- Select Save.
The macro appears on the main Macros page.
Additionally, users in your instance can add it to Confluence pages. When it's added and the page is published, it appears like this: