I have two dropdowns in an activity. One of them it's populated dynamically from OptionsProvider attribute.
I would to like to populate a second dropdown from the first one.
How to get that?
Regards, Gustavo
I have two dropdowns in an activity. One of them it's populated dynamically from OptionsProvider attribute.
I would to like to populate a second dropdown from the first one.
How to get that?
Regards, Gustavo
To achieve this, you need to write a designer plugin that basically does the following:
As an example, I updated the "vehicle activity" sample found
https://github.com/elsa-workflows/elsa-core/blob/master/src/samples/server/Elsa.Samples.Server.Host/Activities/VehicleActivity.cs
.The sample activity demonstrates how one might implement cascading dropdown behavior by letting the user first select the car Brand, then pick a Model from the second dropdown.
Here's what that looks like in action:
The activity's code is straightforward enough, so I will only show its two properties that are of interest:
The most important aspect is the
UIHint
that is set toActivityInputUIHints.Dropdown
- which tells the designer to render the input editor a dropdown.The next step is to create & install a plugin for the designer. Ideally, you already have a StencilJS project in which you encapsulate the designer, but we can do it with just JavaScript directly in your HTML page too. The following snippet shows a scaffold of a plugin and how to install it into the designer:
Now it's up to your plugin to find the appropriate elements when the activity editor is displayed for the custom activity.
For example:
I left out two functions to try and show the structure of the plugin, but here are the missing
awaitElement
andupdateModels
functions:The updateModels function should live inside the plugin, because it requires access to the
httpClientFactory
in this example:The complete plugin code should look like this: