Is this possible (own macro plugin)

I’ve done my first tests/steps with forge.

I was wondering if it is possible to

  1. If I create a Macro with JS, can I have each instance of the Macro (in multiple pages) its own unique ID and then in other Macro code collect these from the current space?
  2. Have a piece of JS code run each time any page in my space changes?

Dear @GerbenWierda

I’m not quite sure whether I fully understand your question(s). Therefore my answers might be wrong.

  1. When you are talking about JS I assume you mean client-side JS (executed in the user’s browser)?
  2. Yes, you can collect pages holding a certain type of macro in another macro. You just have to use the search endpoints provided by the REST API. You can either do that via client side JS in a dynamic content macro or on the server side in any type of macro.
  3. As Confluence Cloud does not offer any possibility to inject client-side JS globally you must implement a webhook and execute your actions on the server side.

I hope that helps.

Best regards

Andreas

Thank you.

My questions might at this stage often be based on not understanding stuff at a deep enough level. I am not certain about for instance the forge hello world app that creates dynamic content in a Confluence page, it seems to me that is all client side, stuff that is run when the page is rendered. But now that I have added a trigger, my guess is that the trigger JS function from my index.jsx is running server-side. Correct?

A link to a good introduction to server-side versus client-side (development) in Atlassian products would be helpful.

I have programmed client-side JS (and many other things) in the past, so I am not totally new to JS code.