Add workflowContext global JS variable

This commit is contained in:
Sipke Schoorstra 2021-04-13 23:01:49 +02:00
parent eb09fcc7ff
commit 5dd2c0be34
3 changed files with 3 additions and 0 deletions

View file

@ -157,6 +157,7 @@ namespace Elsa.Services.Models
public T? GetOutputFrom<T>(string activityName, Func<T?> defaultValue) => (T?) GetOutputFrom(activityName, defaultValue())!;
public T? GetOutputFrom<T>(string activityName, T? defaultValue) => (T?) GetOutputFrom(activityName, () => defaultValue)!;
public void SetWorkflowContext(object? value) => WorkflowExecutionContext.SetWorkflowContext(value);
public object? GetWorkflowContext() => WorkflowExecutionContext.GetWorkflowContext();
public T GetWorkflowContext<T>() => WorkflowExecutionContext.GetWorkflowContext<T>();
public JObject GetActivityData(string activityId)

View file

@ -203,6 +203,7 @@ namespace Elsa.Services.Models
public T GetOutputFrom<T>(string activityName) => (T) GetOutputFrom(activityName)!;
public void SetWorkflowContext(object? value) => WorkflowContext = value;
public object? GetWorkflowContext() => WorkflowContext;
public T GetWorkflowContext<T>() => (T) WorkflowContext!;
/// <summary>

View file

@ -39,6 +39,7 @@ namespace Elsa.Scripting.JavaScript.Handlers
engine.SetValue("input", activityContext.Input);
engine.SetValue("correlationId", workflowInstance.CorrelationId);
engine.SetValue("currentCulture", CultureInfo.InvariantCulture);
engine.SetValue("workflowContext", activityContext.GetWorkflowContext());
// NodaTime types.
RegisterType<Instant>(engine);