{"record":{"id":"61ee721d4215a46b","repo":"OrchardCMS/OrchardCore","slug":"the-syntax-syntax-isn-t-supported-for-ifelsetask","errorCode":null,"errorMessage":"The syntax {Syntax} isn't supported for IfElseTask.","messagePattern":"The syntax (.+?) isn't supported for IfElseTask\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Workflows/Activities/IfElseTask.cs","lineNumber":58,"sourceCode":"        set => SetProperty(value);\n    }\n\n    public WorkflowScriptSyntax Syntax\n    {\n        get => GetProperty(() => WorkflowScriptSyntax.JavaScript);\n        set => SetProperty(value);\n    }\n\n    public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n        => Outcome(S[\"True\"], S[\"False\"]);\n\n    public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n    {\n        var result = Syntax switch\n        {\n            WorkflowScriptSyntax.Liquid => await _expressionEvaluator.EvaluateAsync(LiquidCondition, workflowContext, null),\n            WorkflowScriptSyntax.JavaScript => await _scriptEvaluator.EvaluateAsync(Condition, workflowContext),\n            _ => throw new NotSupportedException($\"The syntax {Syntax} isn't supported for IfElseTask.\")\n        };\n\n        return Outcome(result ? \"True\" : \"False\");\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":64,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Workflows/Activities/IfElseTask.cs#L40-L64","documentation":"IfElseTask evaluates its condition by switching on the activity's Syntax. Only Liquid (LiquidCondition) and JavaScript (Condition) evaluation are implemented; any other WorkflowScriptSyntax value hits the default arm and throws NotSupportedException, so the workflow branch cannot be decided.","triggerScenarios":"Executing an IfElseTask whose Syntax property is not WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript — typically an unset/default enum value, an unrecognized syntax string deserialized from workflow JSON, or programmatic creation without assigning Syntax.","commonSituations":"Hand-edited or imported workflow definitions with stale syntax names after a version change; a newly added WorkflowScriptSyntax member that IfElseTask does not handle; missing Syntax assignment when instantiating the activity in code.","solutions":["Set Syntax to WorkflowScriptSyntax.Liquid and put the boolean condition in the LiquidCondition field.","Or set Syntax to WorkflowScriptSyntax.JavaScript and provide the boolean condition in the Condition field.","Repair the stored workflow definition if it contains a legacy/invalid syntax value.","If a new syntax member exists in the enum, rebuild/update OrchardCore.Workflows so the switch arm is implemented."],"exampleFix":"// before\nvar ifElse = new IfElseTask(); // Syntax unset -> unsupported\n// after\nvar ifElse = new IfElseTask\n{\n    Syntax = WorkflowScriptSyntax.JavaScript,\n    Condition = new JavaScriptExpression { Expression = \"inputs.get('count') > 0\" }\n};","handlingStrategy":"validation","validationCode":"// before running the workflow\nif (ifElseTask.Syntax is not (WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript))\n    throw new InvalidOperationException($\"IfElseTask requires Liquid or JavaScript syntax; got {ifElseTask.Syntax}\");","typeGuard":"static bool IsSupportedSyntax(WorkflowScriptSyntax s) => s is WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript;","tryCatchPattern":"try { result = await activity.ExecuteAsync(workflowContext, activityContext); }\ncatch (NotSupportedException ex) { logger.LogError(ex, \"IfElseTask condition evaluation failed for syntax {Syntax}\", syntax); /* route to error outcome */ }","preventionTips":["Set Syntax explicitly on IfElseTask","Keep Condition/LiquidCondition consistent with the selected syntax","Validate imported workflow definitions","Update activity switches whenever WorkflowScriptSyntax gains members"],"tags":["workflows","unsupported-enum-value","script-syntax","orchardcore"],"backgroundTag":"unsupported-enum-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}