From cd5c7fbb1b073453841b5d67c13f4345180b17bb Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 2 Aug 2023 22:52:02 +0200 Subject: [PATCH] Use correct output name identifiers based on workflow tool version --- .../Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs b/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs index 333214f00..38a676700 100644 --- a/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs +++ b/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs @@ -168,8 +168,13 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator { // Select activities with outputs. var activityExecutionContext = context.GetActivityExecutionContext(); + var toolVersion = activityExecutionContext.WorkflowExecutionContext.Workflow.WorkflowMetadata.ToolVersion; + var useActivityName = toolVersion?.Major >= 3; var activitiesWithOutputs = activityExecutionContext.GetActivitiesWithOutputs(); + if (useActivityName) + activitiesWithOutputs = activitiesWithOutputs.Where(x => !string.IsNullOrWhiteSpace(x.Activity.Name)); + foreach (var activityWithOutput in activitiesWithOutputs) { var activity = activityWithOutput.Activity; @@ -178,7 +183,8 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator foreach (var output in activityDescriptor.Outputs) { var outputPascalName = output.Name.Pascalize(); - var activityIdPascalName = activity.Id.Pascalize(); + var activityIdentifier = useActivityName ? activity.Name : activity.Id; + var activityIdPascalName = activityIdentifier.Pascalize(); engine.SetValue($"get{outputPascalName}From{activityIdPascalName}", (Func)(() => GetOutput(context, activity.Id, output.Name))); } }