What is the purpose of ac:macro-id? Can it be omitted from User Macros?
Asked by Mike Pearson:

Could someone kindly explain - or link to documentation explaining - what the "macro-id" parameter in XML source is used for?

For example, if I create a User Macro that just calls the "cheese" macro twice,  
It could be written as:

    <p><ac:structured-macro ac:name="cheese" ac:schema-version="1" ac:macro-id="6f58a3b3-35a8-4988-9b6b-0ace97bf6478" /></p><p><ac:structured-macro ac:name="cheese" ac:schema-version="1" ac:macro-id="1b7a26f0-73be-4d4c-a46f-6fd2f3463a51" /></p>

or, as:

    <p><ac:structured-macro ac:name="cheese" ac:schema-version="1" /></p><p><ac:structured-macro ac:name="cheese" ac:schema-version="1" /></p>

Both appear to work. ...but **++is there any danger in coding the latter (without the macro-id specified) versus the former?++**

Thanks in advance!


Answers:
author: Bill Bailey
body: I *think* this is a form of globally unique identifier (GUID), and I have assumed it must be unique for every macro instance. I have always deleted it from my user macros that call other macros and have never seen an issue.

comments: author: Mike Pearson
body: Thank you for your input [@Bill Bailey](/t5/user/viewprofilepage/user-id/502089).

I'm also considering simply omitting them in my User Macros. It makes the code a lot more readable and editable (copy/paste without worrying about unique IDs, etc.).

I'm just concerned that without actually understanding what it is for, that I may run into unforeseen issues later on...

Questions for you: you say omitting the macro-id has never been an issue for you...

* Do you use any marketplace plugins? Have they undergone major updates?
* Have you done a major Confluence update (e.g. v5.x -\> v6.x)?
* Have you ever ported your User Macros to another Confluence instance?

These are the kind of future events that I want to ensure won't affect my User Macros if I leave out the macro-ids.

...also, what about the "ac:schema-version" parameter? Do you leave that out as well? Appears to work either way...but again, concerned about the omission causing issues in the future...


author: Bill Bailey
body: Yes to all:

* We use a number of free, and paid plugins from the MarketPlace, as well as custom plugins and a number of in-house developed macros.
* We are currently testing a move from 5.10.8 to 6.2.4. So far have not seen any issues at all with macros. Some of my macros started under 4.x.
* Yes, we (or rather my customer) have multiple development servers. I also run a production and development server, and use and tested some of the same user macros on both -- again zero issues.

I did research the schema issue some time back, but can't find the details. I know there was a change during 5.x. I just ensure that my macros are updated to reflect the new way to call the macros, so yes I include it.


author: Mike Pearson
body: Thanks again for the input [@Bill Bailey](/t5/user/viewprofilepage/user-id/502089). Your testimonial goes a long way to assuage my fears of omitting them.

Another thing that I've discovered that helps, is using the Confluence Source Editor plugin. When I copy any paste my code (without the macro-id or schema parameters present) into a page's source editor, when the page is saved, the Confluence Source Editor appears to automatically reinstate the missing macro-id and schema parameters.

That is to say, both of these parameters can be easily re-instated if necessary.

**...All that said, I think it's safe to say these parameters (macro-id \& schema) can be safely omitted from custom code.**

(even though we never figured out what they are actually for... :p )


author: Chris LaGambina
body: I have iframes in a HTML macro and have been struggling with scrollbars for quite some time. After way too much time trying to figure it out, I find the source code:

\<ac:structured-macro ac:macro-id="bca12819-7ce6-44aa-a55d-4f1f2d006db1" ac:name="html" ac:schema-version="1"\>  
\<ac:plain-text-body\>\<!\[CDATA\[\<iframe src="omitted" width="100%" height="650" scrolling="auto"\> \</iframe\>  
\]\]\>\</ac:plain-text-body\>  
\</ac:structured-macro\>

Specifically the ac:schema-version=1 is what is making my iframes have horizontal scrollbars. After removing this and publishing my page, no scrollbars!

Unfortunately I have found that the Confluence Source Editor appears to automatically reinstate the missing macro-id and schema parameters.

Im no programmer, just trying to edit a confluence page I am building. Any help in trying to figure out a workaround or better way of doing this, please let me know.


Tags: confluence-server

identity

macro

server

storage-format

user-macro