Custom macros are a popular, supported, and versatile addition to any confluence page. Confluence users are able to use macros by making their own, searching the macro library, or by getting access to additional macros through add-ons. If you are making your own macro through an add-on, you will know that the parameter types, aka fields, are limited to the following:
boolean- displays a check box.
enum- displays a select field.
string- displays an input field (this is the default if unknown type).
spacekey- displays an autocomplete field for search on space names.
attachment- displays an autocomplete field for search on attachment filenames.
username- displays an autocomplete field for search on username and full name.
confluence-content- displays an autocomplete field for search on page and blog titles.
Steps for injecting an element into a macro
Building the macro
Example code of plugin.xml
Macro prior to injecting content
Configuring the Soy template multi-select code
JS code with explanation
Why is the Status Parameter Gone?
The drop down multi-select captures the user's selection on the front end. When passing the macro form information back to the server via the preview or the save button, the Status Select format is not readable. To make sure that your information is able to be parsed, you may insert relevant information into another macro field. In this case, the user's responses are sent to the hidden Status parameter each time he/she makes a change to the StatusSelect. On save or on preview, only the hidden information is sent to be parsed.
I only see an empty field when opening the edit macro, I can only see my field when reloading the page with the editable macro, OR I am getting null variable errors.
This may be a JS async error, which could explain some inconsistencies. Make sure that this JS file is accessible to the page, that functions are properly nested, and that the initial if clause is triggered as expected. The edit screen and dialog boxes are not connected to a page reload so queries done "on load" of the page will not be caught at this point. Use .ajaxComplete or an event trigger to re-run necessary functions.
My new element works but now I am missing functionality from other parts of my page.
Make sure that your selectors are unique and as specific as possible. Try to limit using css and JS selectors by the AUI class names as these are repeated through out Confluence.
I am appending my element but only see a blank input box.
Your parameter type may limit the content that can be appended to it. For example, select lists cannot have non-option items added to it and will instead render a broken input box. Confirm that your template has the appropriate wrappers if any. You may need to append your template to the container instead of the parameter.