Replies: 1 comment
-
What you should do is continue with the if/else branching. You got it right with the second attempt (connecting to the next if/else using labels), but you can do it without by simply continuing within the if/else branches, like so: // ... previous activities
.Then<IfElse>(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition1"), ifElse =>
{
ifElse
.When(OutcomeNames.True)
.Then<IfElse>(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition2"), ifElse =>
{
ifElse
.When(OutcomeNames.True)
.Then<IfElse>(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition3"), ifElse =>
{
ifElse
.When(OutcomeNames.True)
.Then("End");
});
}
})
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("End!")).WithName("End") We could make this a bit nicer though. The But we could implement an extension method e.g. .WhenTrue(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition1"))
.WhenTrue(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition2"))
.WhenTrue(activity => activity.ValueExpression = new JavaScriptExpression<object>("condition3"), falseBranch => { /* Maybe do something when things are false*/ })
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("End!")) And in Elsa 2, you could replace the JS expressions with plain C# (statement) lambdas. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. Thanks for the work on this awesome project.
We are considering Elsa to power some customization system in our application. Everything has quite awesome so far. However, we've hit this point of confusion, I'll describe here.
We have a workflow that has multiple boolean flags we'll like to check one after another and perform an activity or 2, for true outcomes ONLY, in the branch. So we have a what looks like the following...
What we've noticed is that if condition1 evaluates to false, the workflow evaluation stops at IfElse1 activity. Our assumption was that the evaluator would continue to evaluating to IfElse2, and finally to End.
What's seemed to work so far, which seems quite :( is the following
Are we missing something that'd allow us maintain the simplicity of the first code block?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions