elsa-workflows / elsa-workflows/elsa-core
Activity with synthetic outputs
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
Hello,
i am trying to implement an Activity wich has inputs and outputs that are generated at runtime based on some configuration in a database.
I used the IActivityProvider to read the configuration from the database and generate activities using an ActivityDescriptor, InputDescriptor and OutputDescriptor.
Since the activity class cannot have the inputs and outputs known at compile time, i used the IsSynthetic flag on the InputDescriptors and OutputDescriptors.
The outputs are described each like so:
```
OutputDescriptor outputDescriptor = new OutputDescriptor()
{
Name = output.Name,
DisplayName = output.Name,
Description = output.Name,
IsSynthetic = true,
IsBrowsable = true,
IsSerializable = true,
ValueGetter = activity => activity.SyntheticProperties.GetValueOrDefault(output.Name),
ValueSetter = (activity, value) => activity.SyntheticProperties[output.Name] = value!,
Type = GetTypeForOutput(output)
};
```
I used the SyntheticProperties to store and retrieve inputs and outputs values.
My Activity looks something like this:
```
protected async override ValueTask ExecuteAsync(ActivityExecutionContext context)
{
object? input = context.EvaluateInputPropertyAsync("SomeInput");
...
SyntheticProperties["SomeOutput"] = 42;
}
```
Retrieving the Input from synthetic properties works.
Writing the output values to synthetic properties works.
After execution of the Activity, the ValueGetter of the OutputDescriptor is called, the value is returned correctly.
So i assume elsa is retrieving the Value from the output to work with it.
But in Elsa Studio, the output values are not shown. They are returned by the Backend to be null.


What could i have done wrong here? Is this even the right approach to build these dynamically generated activities?
Contributor guide
Assessment
This issue has not been assessed yet.