Issue with expression evaluation
See original GitHub issueI’m new to Elsa and find the framework to be very robust. I was easily able to get the engine and workflow designer up and running. I was also able to develop a custom activity with an input parameter defined as follows:
public WorkflowExpression<string> FirstName { get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, “”)); set => SetState(value); }
In this Activity i am setting an output variable as follows: Output.SetVariable(“ProviderOutput”, $“Person:{FirstName}”);
I’ve added this activity to the workflow and set the named instance to ProvOut. I’ve set the FirstName property with a literal value and it’s setting the value appropriately when i step through the custom activity.
I’ve then added the activity into the workflow again to test passing a value from one activity to another. The second activity is passing the FirstName property as follows (the expression type is Liquid): {{Activities.ProvOut.ProviderOutput}}
When i attempt to evaluate this i am getting an object reference error from the LiquidExpression evaluator. Here is a snippet of code from the OnExecuteAsync() method:
var firstName = await expressionEvaluator.EvaluateAsync( FirstName, workflowContext, cancellationToken );
My services are configured as follows:
services
.AddElsa(elsa => elsa.AddEntityFrameworkStores<SqliteContext>(options => options.UseSqlite(Configuration.GetConnectionString(“Sqlite”))))
.AddHttpActivities(options => options.Bind(Configuration.GetSection(“Elsa:Http”)))
.AddEmailActivities(options => options.Bind(Configuration.GetSection(“Elsa:Smtp”)))
.AddActivity<MapProvider>()
.AddTimerActivities(options => options.Bind(Configuration.GetSection(“Elsa:Timers”)))
.AddElsaDashboard();
This is the error i am receiving: “Error while evaluating Liquid expression "{{Activities.ProvOut.ProviderOutput}}". Message: Object reference not set to an instance of an object.”
And here is the stack trace
" at Elsa.Expressions.WorkflowExpressionEvaluator.<EvaluateAsync>d__3.MoveNext()\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\n at Elsa.Extensions.WorkflowExpressionEvaluatorExtensions.<EvaluateAsync>d__01.MoveNext()\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\n at ElsaCustomActivities.MapProvider.<OnExecuteAsync>d__6.MoveNext() in /Users/larrymartin/Projects/ElsaTest/ElsaCustomActivities/Class1.cs:line 42"
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)

Top Related StackOverflow Question
Thanks! That’s exactly what i needed. I now have a dev environment set up and i’m able to step through the code.
Thanks Spike. I’ve now submitted a PR for review. I was able to confirm the code change worked as expected by creating an activity and assigning a name. I then checked the database (was using EF as persistence) and could confirm after making the change the Name column in the datastore was set. For testing i was using EF and SQLLite.