I’m trying to create a web form macro which has text boxes, check boxes, drop downs etc.
I would like the data to persist on reload, and be per instance. They’re will be maybe 100 instances on a single ‘review’ page.
I think this means I need to store the data in the macroconfig.
I can read the macroconfig in both ui kit and custom ui. But I can’t see how to save the data so it persists.
Using the sidebar config isn’t really an option as it doesn’t really flow with the quick review of items that I’m looking for.
I also need to be able to pick up the data once saved via rest calls to port it to a different tool.
Maybe i’m going about this the wrong way, so any advice would be appreciated
I would use Forge Storage. It’s a persistent key value store for Forge and it seems like it’s exactly what you need.
For your external tool, you will need to push the data to it from Forge. For example, a REST call when the user submits the form. There is currently no way for you to retrieve data from Forge storage outside the context of your Forge app (that I am aware of).
You can not persist Macro data from the macro view, only from the editor. This is a security constraint. You can post the data to your own function and store the data in Forge Storage, as also mentioned by @Ryan, but there is a tricky part to this as it is difficult to link said data in storage to a specific Macro. Confluence does have macro IDs, which you should be able to retrieve from context, but those macro ID’s are not persistent. A macro ID can change when a page is edited.
There is no easy solution to this. Your best bet is to require some sort of initial macro editing, in which you put a placeholder form ID in the macro data and store all form entries against that form ID. That is the only way to have a persistent identifier for that specific macro in your database.
Thanks for your help folks,
Actually the data for the individual macros are stored in bitbucket,
The issue is that there will be multiple Macros on the page that need to access the same data.
i.e. there will be a Macro form, some user editable data, another macro form etc.
Each Macro form will have a unique entry in the data structure.
I really only want to get the data once when the page loads, and save/commit it after the forms have been populated.
To do this I think I need to create a new macro which loads the forge storage from bitbucket, and then my other macro instances can access it from there.
This is all a bit convoluted, but I am constrained by other users who want to be able to edit the content between Macros in a specified manner, If it was text only I’d just pull all the data into bitbucket, but unfortunately we need to support images too.
I’ll let you know how I get on…
I too am working on a macro that needs a persistent macro id, even on save. @remie Is there really no way for the macro to create a unique identifier when first created and to save it?