Best Practice for Configuring a Macro And Storing the Config?

Hi guys,

I am currently working on a Connect add-on and would like to configure a Dynamic Content Macro via User Input. I.e.:

User opens macro → Dialog is shown → user provides a value for configuring the macro → dialog closes and macro is executed with the value provided as a parameter

So far I have implemented that. Now I wonder what is best practice in order to save the configuration of the macro so that the user does not have to configure the macro every time.

Is there a way to add this to the macro directly on the client (bind it to the item on the confluence page), or should it rather be saved on the server?

Is there a sample code for this that you can look at?

Best regards

Hi @Cust0mFirmware,

It sounds like you are already using macro parameters (which should be the solution to your problem), so I’m wondering what you mean by this:

Maybe you could share the parts of your atlassian-connect.json where you have defined your macro and elaborate on what your users actually have to configure when they insert or edit your macro?

Cheers,
Sven

1 Like

Hi @sven.schatter,

thank you for the answer, that was very helpful for me!

No, I had not used macro parameters.
Actually the user should only be able to enter a URL via a dialog.

If I understood it correctly, I could implement this like this:
Use the macro → Dialog pops up → Enter URL → Macro is inserted within the Confluence page(with the URL as a parameter) → Based on the parameter the macro can deliver the desired response

Is this the usual approach?

Best regards

Hi @Cust0mFirmware,

It sounds like you’re on the right path. You can create a custom macro editor (see the editor property in the dynamic content macros documentation to provide a custom experience for entering the URL). The parameters can be saved and retrieved with the saveMacro and getMacroData Javascript APIs.

If the macro isbn’t declared as cacheable, you can pass the macro parameters to your macro view using context parameters. For example, if you call saveMacro({myUrl: foo}), you can specify the URL of your macro view as .../my-macro-view?my-url={myUrl} so that it is easily obtainable from your view.

Regards,
Dugald

5 Likes

Hi @dmorrow

Thank you very much for the detailed explanation and the useful links.
Now, I think that I’m on the right track and I will start to change my implementation as soon as possible!

1 Like