Setting confluence macro config programmatically

Hello :slight_smile:

When using a Confluence macro with a macro configuration, changing the configuration is considered as a page update by Confluence.
Confluence is considering that changing the way the macro is rendered (based on the configuration) is actually changing the page content.

Now letā€™s consider a confluence macro storing content using the Storage API or any product REST API. When the content of the macro changes since there is no configuration change (or no configuration at all) then Confluence does not consider it a page content update, although the page content did actually change since the macro content did change.

We are looking for a way to indicate an update of macro content as a confluence page content update.

For example, we could make a hash of the macro content, then store the hash as a macro configuration property. Confluence would detect the change of configuration and then mark the page update.
Problem is: how to read/write confluence macro config programmatically without UI. Is that even possible.

On the other hand, if any of you has a proposal to update a confluence page version when macro content is updated, Iā€™m all ears :ear:

Thanks !

1 Like

Do you have a way to make a hash of the macro content? I believe this is impossible in general, as a macro might be just an iframe loading data from another system or e.g. the include macro.

how to read/write confluence macro config programmatically without UI. Is that even possible.

I donā€™t think it is possible.

On the other hand, if any of you has a proposal to update a confluence page version when macro content is updated, Iā€™m all ears :ear:

Actually, it could be a good workaround. You can update a page version at any time using the REST API: Confluence REST API - Update Page.

To do this, simply include a message such as ā€œMacro ā€˜NAMEā€™ configuration changed.ā€ The author of the change will be automatically set to the current user if you send the PUT request from the front end on behalf of the user making the configuration changes to the macro. It can be a bit tricky since you need to increment the current version each time, meaning you need to know the current content version. However, this shouldnā€™t pose a significant problem.

Thanks @AndreiPisklenov, thatā€™s what popped in my mind the moment I hit the publish button for this post :face_with_hand_over_mouth:

In our case, the macro content data is fetched and the macro UI is displaying the content, so yes we could hash the content and detect if and when the content changes in the Forge code.

1 Like