tl;dr how can i have a workshop button trigger a message in workshop ‘response submitted’ whilst also triggering an async typescript function.
We have a workshop module in development. It has a button which triggers an event to ‘recalculate a variable’ . This variable calculation actually is a typescript function to asynchronously post to an external api with a webhook configured in palantir data sources.
But this button from the ui side doesn’t seem to do anything to the user. Therefore users will spamm it or think its broken. Ideally we would show a confirmation and optionally a parallel toast widget with success/failure message.
As a workaround I tried clearing the user selection in parallel to the post, but the clearing is faster then the posting so the posting fails. Which is also confirmed by the docs of Palantir button group : https://www.palantir.com/docs/foundry/workshop/widgets-button-group/e.g
another option i tried was collapsing the section where the button is in, but this also seems to hold/stop the post to myquest.
How do you guys normally do this? I cant imagine this isn’t possible in workshop …
A workaround you can apply that’s visually striking (it will gray out the entire module) is adding an event that opens an overlay with a success/error message in the middle of the user’s screen.
Steps to consider:
Create a new Overlay – set it to Modal (so it floats in the middle of the screen) and adjust its size
Add either a Markdown widget or a Metric Card widget (if you want a custom background color like green or red), and feed the widget a string variable with your “success” or “error” message
In the specific button that triggers the variable re-calculation, add a second event after it which opens your new Overlay from step 1 above
You can customize this modal as well if your webhook returns a response code and a potential error message.
I don’t know any good way to make a pop-up blink in and out here, but an alternative option is to conditionally disable the button when the variable is up to date and conditionally set button text with a string variable. For example, a clickable “Update Variable” button becomes a disabled “Variable Updated!” button. If you’d like the button color to change, then this can be accomplished with two buttons: a clickable one and a disabled one that are each conditionally shown/hidden depending on the state of your variable.
I was able to link the function to an action in the ontology, and triggers this action with the said button. The action comes out of the box with a notification when the button is clicked. which resolves my need nicely.