Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation to check for page macros

Ian MacDonald
Contributor
April 2, 2025

Hello,

I have been having some trouble building an automation that checks for various items on a page when it is edited. This is part of a document compliance effort to ensure people are not using certain macros in specific controlled spaces.

I have managed to put together some simple macros (see image) that check for a macro on the page, but I run into issues when I want to check for multiple different macro types.

 

macro.png

 

I have tried using an IF/ELSE branch with multiple checks for macros. It seems to always return as TRUE even when none of the conditions are met on the page.

macro 2.png

 

I feel like there must be a more elegant solution that I am overlooking, and any advice on how to check a page for macros would be very helpful. Thank you!

2 answers

2 accepted

1 vote
Answer accepted
Kristian Klima
Community Champion
April 3, 2025

@Ian MacDonald 

Just to add my 5 cents, in Confluence settings, there's the Macro usage section.

It lists unused macros and then all used ones. Click the macro name, and search page opens - listing all pages where that macro is in use. By using the filter, you can narrow down the time scope etc.

It's not meant for real-time control, but might be useful for housekeeping.

2025-04-03_12-46-20.png

Ian MacDonald
Contributor
April 4, 2025

Oh this is really helpful, surprised I have never stumbled upon this section before, thank you!

Like Kristian Klima likes this
Stacie Bacon April 21, 2025

Do you know if you can get at the values from a macro?

Like Kristian Klima likes this
Kristian Klima
Community Champion
April 22, 2025

@Stacie Bacon 

I'm not sure, I know that you can get, for example, values from Excerpt macros in Confluence Databases.

Like Stacie Bacon likes this
1 vote
Answer accepted
marc -Collabello--Phase Locked-
Community Champion
April 2, 2025

Hi @Ian MacDonald ,

Not sure why your automation is not working.

One thing you can do to streamline he macro detection is to use a condition like

macro in (toc, widget) 

in a CQL Condition in an if-block.

However for compliance it is probably better to work with an allowlist of macros instead of listing all forbidden macros:

macro not in (allowedMacro1, allowedMacro2)

We use a similar approach when we search for pages for our Document Control macro.

 

Ian MacDonald
Contributor
April 2, 2025

Hi Marc,

Thank you for the response! I am trying out your suggestion of "macro in ('excerpt', 'include') and this seems to be working. I was not able to get it to work when I did "macro in ('Insert excerpt', 'include page') for some reason. 

Do you happen to know if there is an ID I could call instead of the name of each macro?

marc -Collabello--Phase Locked-
Community Champion
April 2, 2025

If you need to know the exact macro names, your best bet is to insert the macros on a page.  Then click on the top right three dots, choose "Advanced details" - "View storage format".

The macro names in the storage format follow the the string ac:name, e.g.

ac:name="expand"

for the expand macro.  This ac:name is like an id and unique as far as i know.

marc -Collabello--Phase Locked-
Community Champion
April 10, 2025

Hi @Ian MacDonald ,

This might be important for you:  I believe the CQL search only returns macros made with "Connect", the previous extension framework Atlassian used.

The current extension framework uses "Forge", and I believe Forge macros are not returned.

Like Ian MacDonald likes this
marc -Collabello--Phase Locked-
Community Champion
April 23, 2025

Hi @Ian MacDonald ,

There is now a public ticket to work on including Forge macros in the listing: https://jira.atlassian.com/browse/CONFCLOUD-81490

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events