elsa-core
elsa-core copied to clipboard
Set variable value before execution programmatically
I'm using Elsa 3.2, in a custom INotificationHandler<WorkflowExecuting> I want to add a new variable to the workflow variables before its execution; the problem is that WorkflowExecutionContext.Variables is immutable... how can I do?
Hello,
what have you done ?
For example, I use : INotificationHandler<WorkflowExecuting>
And then in the implementation
public Task HandleAsync(WorkflowExecuting notification, CancellationToken cancellationToken)
{
notification.Workflow.Variables.Add(new Elsa.Workflows.Memory.Variable("MyCustomVariable", "MyCustomValue"));
}
This should works.
It works, thank you!
My code wasn't working because I used "notification.WorkflowExecutionContext.Variables" instead of "notification.Workflow.Variables"... What is the difference between these two?