I’m creating the dynamic macro using ACE and I’m having troubles with reading macro properties when editing page after macro is updated.
Here is my situation…
I have ‘dynamicContentMacros’
"modules": {
"dynamicContentMacros": [{
in the macro there is a parameter
"parameters": [
{
"identifier": "name",
Here is what I do:
- Go to Edit Page
- insert macro to the page
- click ‘Edit’ icon on the macro
- change the name on the edit dialog
- save it
After edit dialog is closed the dynamic macro is reloaded.
Inside the macro I do AP.confluence.getMacroData()
call to get macro parameters.
The problem this that it returns outdated (previous) value of the ‘name’ field. As a result on the edit page after editing macro properties the old version of the macro is displayed. That is very confusing.
I’ve tried various ways to get the data updated and nothing helps. Data is also not updated if you send the request later (like 10 secs after it was edited) etc.
The only way to resolve the issue is either Publish the page, then on the ‘view page’ mode the AP.confluence.getMacroData()
will give the updated value. Also it is possible to refresh the edit page, then the value will be updated as well.
I’ve tried to resolve the problem by reading the macro parameters using REST API call
GET /wiki/rest/api/content/{id}/history/{version}/macro/id/{macroId}
It works fine when the macro is on ‘view’ page and first loaded on the ‘edit’ mode. After editing the parameters of the macro the API call starts returning 404 error until page is published.
com.atlassian.confluence.api.service.exceptions.NotFoundException: No macro found on content id : ContentId{id=1336180753} with version: 38 and macroId: be87d90f-fe24-4992-b372-936022f4e2ff
The only reliable way I found to get the updated parameters is from the URL request parameters.
"url": "/v1/macro?pageId={page.id}&pageVersion={page.version}¯oId={macro.id}&name={name}",
The problem is that potentially the data can be very long (not for the name but other parameters) and it can potentially harm the browser, server etc.
Am I doing something wrong here? Is there a way to make things work properly? Is this a bug and should I create a ticket? Where?
Thanks,
Andrey Stepanov