elsa-workflows / elsa-workflows/elsa-core

Activity with synthetic outputs

Open
#6,551 0 comments 0 reactions 0 assignees View on GitHub
triaged
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.

![Image](https://github.com/user-attachments/assets/ce528809-3eba-4ff7-9a8b-04e85e6ff778)

![Image](https://github.com/user-attachments/assets/4aaf053a-eafa-4267-b53c-303626d97132)

What could i have done wrong here? Is this even the right approach to build these dynamically generated activities?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.