I have the next problem. I’m exporting page with macro (only table from UI Kit). In pdf it’s clear but in Word I have notification that it’s impossible to export this macro.
In this tutorial I found how to use adfExport Function to export macro in Atlassian document format.
But I still didn’t find the next main points:
- How to get Config for this macro (because all necessary data for export stores in this config)?
- How to invoke my resolver function to get data from Back-end? (Example use only Confluence API, but not application backend)?
1 Like
For config, this tutorial might help.
To reach your app’s backend, you likely want the invoke
method.
Config stores in context.extension.config
and adfExport function has only this fields in context:
{
"context": {
"accountId": "string",
"cloudId": "string",
"contentId": "",
"extensionContext": {
"type": "macro"
},
"extensionData": {
"content": {
"id": ""
},
"isConfig": false,
"space": {
"key": ""
},
"type": ""
},
"isConfig": false,
"localId": "",
"moduleKey": "",
"spaceKey": ""
},
"exportType": "word",
"contextToken": ""
}
To invoke method I need properties for filtering data from config but I don’t know how I can have an access to this config from adfExport function
This tutorial is for UI Kit, not for back-end function such as adfExport function!
Sorry for the too quick response. I see now that the export functions are only for UI Kit 1, not a supported version of the UI Kit. The original tutorial isn’t up-to-date. (The naming convention doesn’t help.)
It seems like there was a recent change to allow config to be accessed for PDF export, but it seems they didn’t extend that to Word. @JakeStrauss might know more.
For the backend, is it a remote backend? If so, I’d use Forge remote.
It seems that now it is impossible to export Forge UI Kit application in Word, only in PDF (Native PDF export works well).
OK, let’s wait for decision from the Atlassian side.
Hello @IgorKosarev
I am an Atlassian engineer currently working on the macros experience.
I wanted to find out more about the issues you are running into, and propose some solutions.
Firstly, with config
, it is accessible on the top level payload that is provided, not as a child of context
:
export const adfExportFunction = async (payload) => {
const config = payload.config;
}
Secondly, for sharing logic between your resolver function and your export function, you don’t need to call the resolver itself, instead, you could just call a shared function that you use in your resolver.
There may be differences in the properties provided in the context, so check any properties you need are available in both context
from the resolver and the export function.
function sharedLogic(context) {
console.log(context)
}
const resolver = new Resolver();
resolver.define("getText", (req) => {
sharedLogic(req.context)
})
export const handler = resolver.getDefinitions();
export const adfExportFunction = async (payload) => {
sharedLogic(payload.context)
}
Finally, for the Word export issue, I have not been able to reproduce this on my side, I am successfully able to export Custom UI and UI Kit 2 macros to Word.
Can you perhaps share some more details about the issue that you are running into, and also share the macro definition from your manifest.yml
file?
Thanks!
Hi, @SamLeatherdale
OK, I got the first and second point.
When I export to Word from Forge app (UI Kit 2) I have the next result:
We don’t have a way to export this macro.
It happens if I don’t use adfExportFunction.
My manifest.yml
now is:
macro:
- key: my-app-key-macro
resource: page-macro
render: native
resolver:
function: resolver
title: Title
config: true
icon: resource:resources;icons/main_logo.svg
It works perfectly for PDF but doesn’t work for Word export.
I have tried to use adfExportFunction
(I added it into manifest.yml
and it works with “Hello word” paragraph) but I didn’t understand how to get data from macro config (settings from the right macro editing panel in UI). I can get data from my back-end functions without resolver but I need data from macro config.
Hi @IgorKosarev
I can’t see the adfExport
defined in your manifest.yml
To properly use the ADF export feature, you must define it in your manifest, like so:
macro:
- key: my-app-key-macro
adfExport:
function: adf-export-function
# other macro properties
function:
- key: adf-export-function
handler: exportFile.adfExportFunction
Then, in your ADF export function, you will be able to access the config via payload.config
, as demonstrated above:
export const adfExportFunction = async (payload) => {
const config = payload.config;
}
This should work for PDF and for Word.
Hi @SamLeatherdale
OK, I use this payload like this:
import { doc, p } from '@atlaskit/adf-utils/builders';
export const adfExportFunction = async (payload) => {
const config = payload.config;
return doc(
p(`Config: ${config}`),
p(`Payload: ${JSON.stringify(payload)}`)
);
}
I’ll get the next result:
As you can see there are no config
data
It is my question: “How I can get config data?”
My manifest.yml
is:
macro:
- key: my-app-for-confluence-macro
resource: page-macro
render: native
resolver:
function: resolver
title: App title
config: true
icon: resource:resources;icons/logo.svg
adfExport:
function: adf-export-function
Hi @IgorKosarev
I am able to see the config
object in my test export:
Can I confirm that you are:
- Adding config to your macro using
ForgeReconciler.addConfig
as described in the docs?
- Clicking the edit button on the macro and setting some config properties in the right-hand sidebar, then publishing the page, before attempting to export it?
Even if you have added config to your macro from the code side, you need to actually populate each macro you insert into a page with config values for them to appear in the export.
If this doesn’t solve the issue for you, then I would have to suggest raising a support ticket with Developer and marketplace support so they can undertake more detailed troubleshooting with you.
Hi @SamLeatherdale
It was the problem from number 2. Config didn’t specify in the right-hand sidebar (a lot of experiments with it and I forgot to confit it when I was trying to export for now).
Now I get the config in my adfExport function.
Thank you!
1 Like
Hi @SamLeatherdale
It is an another problem with config.
For PDF and for Word export it has absolutely different location in payload:
The problems:
- Different locations for
config
object
- If confit attribute is a string with not latin characters there is “???” in this attribute for this characters for Word export.
Is it expected behavior for adfExport Function or is it a bug?
Hi @IgorKosarev
These are definitely bugs and are not expected.
I have gone ahead and raised two public bugs that you can follow for updates:
Thank you for reporting these issues.
1 Like