How to generate a correct UUID for a macro

Hi,

I’m using a Forge webtrigger to update a page, and insert a macro into a page.
This is all going well, I can insert this macro without any problem.

However, I have to do this with a fixed UUID for the macro. If I don’t add a UUID, I get an error when rendering the page, if I auto-generate a UUID with the uuid-random library, the macro is unknown. Apparently Confluence doesn’t accept these auto-generated uuids.

This is causing caching issues (the cache is apparently linked to the uuid, and this means that the results of the previous page are also shown on the second page), and is quite problematic for this solution.

How can I generate new UUIDs that Confluence accepts as valid macro-uuids?

When inserting a macro into a page, there are multiple UUIDs involved, and only one of them (localId) can be randomly generated. Could you share an example of the macro you tried to insert?

Hi,

This is the macro I’m trying to insert:

<ac:adf-extension>
    <ac:adf-node type="block-card">
        <ac:adf-attribute key="layout">full-width</ac:adf-attribute>
        <ac:adf-attribute key="datasource">
            <ac:adf-parameter key="id">361d618a-3c04-40ad-9b27-3c8ea6927020</ac:adf-parameter>
            <ac:adf-parameter key="parameters">
                <ac:adf-parameter key="schema-id">8</ac:adf-parameter>
                <ac:adf-parameter key="aql">ObjectId = xxx-xxx-xxx</ac:adf-parameter>
                <ac:adf-parameter key="workspace-id">xxxx-xxxx-xxxx-xxxx</ac:adf-parameter>
            </ac:adf-parameter>
            <ac:adf-parameter key="views">
                <ac:adf-parameter-value>
                    <ac:adf-parameter key="type">table</ac:adf-parameter>
                    <ac:adf-parameter key="properties">
                        <ac:adf-parameter key="columns">
                            <ac:adf-parameter-value>
                                <ac:adf-parameter key="key">228</ac:adf-parameter>
                            </ac:adf-parameter-value>
                            <ac:adf-parameter-value>
                                <ac:adf-parameter key="key">3393</ac:adf-parameter>
                            </ac:adf-parameter-value>
                            <ac:adf-parameter-value>
                                <ac:adf-parameter key="key">3465</ac:adf-parameter>
                            </ac:adf-parameter-value>
                        </ac:adf-parameter>
                    </ac:adf-parameter>
                </ac:adf-parameter-value>
            </ac:adf-parameter>
        </ac:adf-attribute>
    </ac:adf-node>
    <ac:adf-fallback>
        <ac:adf-node type="block-card">
            <ac:adf-attribute key="layout">full-width</ac:adf-attribute>
            <ac:adf-attribute key="datasource">
                <ac:adf-parameter key="id">361d618a-3c04-40ad-9b27-3c8ea6927020</ac:adf-parameter>
                <ac:adf-parameter key="parameters">
                    <ac:adf-parameter key="schema-id">8</ac:adf-parameter>
                    <ac:adf-parameter key="aql">ObjectId = xxx-xxx-xxx</ac:adf-parameter>
                    <ac:adf-parameter key="workspace-id">xxxx-xxxx-xxxx-xxxx</ac:adf-parameter>
                </ac:adf-parameter>
                <ac:adf-parameter key="views">
                    <ac:adf-parameter-value>
                        <ac:adf-parameter key="type">table</ac:adf-parameter>
                        <ac:adf-parameter key="properties">
                            <ac:adf-parameter key="columns">
                                <ac:adf-parameter-value>
                                    <ac:adf-parameter key="key">228</ac:adf-parameter>
                                </ac:adf-parameter-value>
                                <ac:adf-parameter-value>
                                    <ac:adf-parameter key="key">3393</ac:adf-parameter>
                                </ac:adf-parameter-value>
                                <ac:adf-parameter-value>
                                    <ac:adf-parameter key="key">3465</ac:adf-parameter>
                                </ac:adf-parameter-value>
                            </ac:adf-parameter>
                        </ac:adf-parameter>
                    </ac:adf-parameter-value>
                </ac:adf-parameter>
            </ac:adf-attribute>
        </ac:adf-node>
    </ac:adf-fallback>
</ac:adf-extension>

There is no localId in this macro, and the id here causes caching issues.

There is no localId in this macro. And if you add the macro manually, each macro gets a new id.

Maybe someone from the Assets team could chime in?

Sorry, I thought you wanted to insert a Forge macro. In this case, I don’t know what the UUID is referring to. :slightly_frowning_face:

1 Like

Ah, no. Indeed a normal Confluence macro, not a forge macro from my plugin.
Thanks for helping me clarify this and for trying to help!

1 Like

Hi @JoachimBollen ,

The API here is a little murky. I ran into a similar problem when helping create the blog How to Build a Cross-product Forge App for Jira and Confluence. We added a tip in step 3 explaining our approach after consulting with the Confluence Ecosystem team. I’m sorry we can’t provide clearer semantics.

Regards,
Dugald

Hi @dmorrow ,

Thanks for responding. If I understand correctly, I should leave the ‘id’ empty, and Confluence will autofill it afterwards?

I’ve tried this and it works fine for a standard macro, but I’m trying to use the new Assets macro, and there, there’s no macro-id present, only an id pointing to the datasource. Leaving this id empty causes a failure of the macro, so this isn’t a solution here.

Any idea how I can get a valid and unique id to insert here?

2 Likes