How to use Macro Configuration with Custom UI apps in Forge

Hi! I really don’t know a nice way to do this but I want to add configuration settings to my macro that uses custom UI kit. At the moment the custom UI app and confluence configuration are working separately there is no way for them to interact with each other. I tried to use the resolver but it only works when the custom UI invokes forge app but what I want at the moment is to invoke the custom app from my forge app in order to send data from the forge app to the custom app.

Hi @GbemiKadri,
If I understand you correctly, you have two macros, one custom UI, and one UI kit.
The UI kit one has macro configuration, and you’d like the custom UI app to be able to read that. Is that correct?

Hi! Ryan, you did, yes, this is what I want.

Unfortunately, that’s not really a supported use case as macro config is tied to the instance of a macro, rather than the app itself.

Technically, you can fetch the ADF version of the page with the REST API (/wiki/rest/api/content/{contentId}?expand=body.atlas_doc_format) and then parse it for the guestParams of the macro.

Can you describe your use case a bit more? Is there a reason why you don’t have a single custom UI macro with config?

Actually, the main idea is to add macro configuration to an existing custom ui macro. The plan is to use the data received from the configuration to filter the data in the custom ui macro. So I want to do exactly this https://developer.atlassian.com/platform/forge/add-configuration-to-a-macro/ but with custom ui macro. Correct me if I am wrong but at the moment, I noticed that I can only achieve this solution when I use UI kit macro. This was the reason behind my first question of transferring configuration data.

Sorry for the delayed response, you can use config with a custom UI macro.

You still define your config function with UI kit, and hook it up to your macro in the manifest.

Access the config via your resolver

3 Likes

Please could you elaborate on this? Are you saying you can provide a second static resource for the config?

Are you saying you can provide a second static resource for the config?

No, the config must be defined using UI kit. Take a look at https://developer.atlassian.com/platform/forge/add-configuration-to-a-macro/ for how to define it.

I have read that…

I am trying to do something different to what this thread is asking for. I am trying to use a custom UI for the macro config. I want to add a text field that the user can enter in a jira filter into. I then need to pass this string into the filters REST API.

The config must be defined using UI kit. It is not possible to use custom UI for macro config.

Hey @Stoff81, to add on to what @RyanBraganza has mentioned, we currently don’t have the capability to define macro config using custom UI, but you can use UI kit to define macro config for your Custom UI macro.

From your brief description, it sounds like you should be able to use a UI kit macro config with a TextField to achieve your use case. If not, we’d love to hear more about your use case. We know that there are use cases out there that need custom configuration screens.

I have tried that but TextField has no callback method in which to access the string entered. If there was something like Buttons onClick then I think I could make it work.

The text the user inputs into that textfield (and any other config field) will be saved into the page’s content (hidden), and is accessible in the macro itself (via useConfig in UI kit or via view.getContext or in the resolver function parameters in Custom UI).

Is that what you need? Or do you need to access it within the macro config itself, and if so, why?

Hey,

Yes I am aware of the options you suggest. I need the text inside the config. I’m trying to let the user search for and select a jira filter inside the config.

1 Like

I see, I think I understand the use case a bit better now. Sounds like a Custom UI configuration screen is necessary. Perhaps you could also try a Select field in UI kit macro config, if you haven’t already considered that. Could be tricky though, especially if there are many filters to choose from.

Yeah tried that already. Select works perfectly if you less that 100 filters but the minute you need to pass a search queury to the api it’s no good.

1 Like

It would be ideal if the Select widget had an onChanged callback so I could plumb that into the api call

2 Likes