How to fix add-on macro view in subscription / notification e-mail

i’m developed a atlassian connect add-on as a Dynamic Content Macro for confluence.
i did start my first steps based on ac-gmaps project.

Now my add-on is release but i did figure out that the notification e-mail doesn’t look pretty well.
of course the same way as the Maps-addon here:

what do i need to do or configure in the description-file that the notification e-mail does render my macro html and won’t show only the value of my url-parameter data ?

part of the description-json file:

 "modules": {
        "dynamicContentMacros": [
            {
                ...
                "url": "/macro?data={data}",
                ...

regards
lutz

Hi Lutz, I ran into this same issue with dynamicContentMacros, and found out that the only way to display properly in any sort of export (e-mail, pdf, etc.) is to use a staticContentMacro (i.e. render something server-side).

Notice the message on https://developer.atlassian.com/static/connect/docs/latest/modules/confluence/dynamic-content-macro.html:
Since Dynamic Content Macros are rendered in an iframe, you are able to include your own style sheets and javascript. You can use these to create a rich, interactive experience for your users. When your macro is exported to a static format such as PDF or Word, you can use the renderModes property to define a mapping between a certain type of output device and a static macro implementation. This will allow you to create a static view of your macro’s data where an interactive model is not appropriate.

Hi stephen aka @stephendeutsch1
Thank you for your reply, i will check this out now.

Regards
Lutz

Hi again stephen aka @stephendeutsch1
Do you know how can i pass my stored json-object ( {data} ) to the new static-view ?

Regards
Lutz

this is not working for me. when i change my description file like that:

                "renderModes": {
                    "email": {
                        "url": "/macrostatic.html"
                    },
                    "default": {
                        "url": "/macrostatic.html"
                    }
                },

the whole macro-json object view disappears but it shows only
...
instead.

The Html macrostatic.html is accessible directly, so it should work.
Any ideas ?

Regards
Lutz

Hi Lutz,

If you want your ‘data’ object to be passed through, you need to add it as a url parameter as with the dynamicContent macro you described above, eg "url": "/macrostatic.html?data={data}". Does that help?

Cheers,
Kate

The renderModes is not working for me to layout/design generated atlassian notification emails.

GET macrostatic.html only happens when i’m clicking “Export as PDF” manually in confluence.

"modules": {
        "dynamicContentMacros": [
            {
                "url": "/macro?data={data}",
                "renderModes": {
                    "email": {
                        "url": "/macrostatic.html"
                    },
                    "default": {
                        "url": "/macrostatic.html"
                    }
                },
...

Any ideas what’s still wrong ?

Hi Lutz, you should be aware that you can’t use an HTML for a static content macro, it returns Confluence Storage Format (XHTML), so it should be rendered server-side before being output. A purely client-side addon using only HTML to render content will be unable to do this.

Although if you are using the content just as a placeholder, then this would probably work fine :wink:

1 Like

Hi @stephendeutsch1

I did also try to render the add-on content at server side but it has the same effect.
The content of my view will be not rendered in the notification email.

The Endpoint /macrostatic will be never requested except when i start the export process manually via “Export to pdf” function in confluence.

"modules": {
        "dynamicContentMacros": [
            {
                "url": "/macro?data={data}",
                "renderModes": {
                    "email": {
                        "url": "/macrostatic"
                    },
                    "default": {
                        "url": "/macrostatic"
                    }
                },
...

index.js

    app.get('/macrostatic', addon.authenticate(), function (req, res) {
        res.render('macro-view-static');
    });

macro-view-static.hbs (contains only this string)
lalalalal

May be i don’t understand your explanation but did you fix the notification email style with the renderModes or just the style of export ?

In case of yes, can you please provide a short example

Thank you & Regards