From 17452f740c3129e0681c529fd66201474c12629e Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 29 Dec 2023 18:51:31 +0100 Subject: [PATCH] Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. --- src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs b/src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs index ad4dc9ab95..8265840d35 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs @@ -5,6 +5,7 @@ using Elsa.Workflows.Attributes; using Elsa.Workflows.Memory; using Elsa.Workflows.Models; +using Elsa.Workflows.UIHints; using JetBrains.Annotations; namespace Elsa.Workflows.Activities; @@ -100,7 +101,10 @@ public SetVariable([CallerFilePath] string? source = default, [CallerLineNumber] /// protected override void Execute(ActivityExecutionContext context) { + // Always refer to the variable by ID to ensure that the variable is resolved from the correct scope. + var variableId = Variable.Id; + var variable = context.ExpressionExecutionContext.EnumerateVariablesInScope().FirstOrDefault(x => x.Id == variableId); var value = context.Get(Value); - context.SetVariable(Variable.Name, value); + variable?.Set(context, value); } } \ No newline at end of file