You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Camunda用户任务嵌入HTML表单报错:值'on'非布尔类型求助

Fixing "Camunda Form failure: Value 'on' is not of type boolean" Error

Hey there, let's work through this Camunda form issue you're hitting—it's a super common gotcha with HTML forms in Camunda!

What's Causing This?

This error almost always stems from a checkbox (or toggle-style control) in your HTML form being bound to a Camunda variable defined as a Boolean type. By default, when you check a standard HTML checkbox, the browser sends the string value 'on' instead of a proper boolean true/false. Camunda throws an error because it expects a boolean but receives a mismatched string type.

How to Fix It

Here are two straightforward solutions to resolve this:

1. Use Camunda's Form Directives to Map Boolean Values

Camunda has built-in directives to handle boolean form controls correctly. Add these attributes to your checkbox input to ensure it sends valid boolean values to Camunda:

<input type="checkbox" 
       cam-variable-name="yourBooleanVariable" 
       cam-variable-type="Boolean"
       cam-true-value="true" 
       cam-false-value="false"
       id="approvalCheckbox">
  • cam-variable-type="Boolean" explicitly tells Camunda to treat this variable as a boolean type.
  • cam-true-value and cam-false-value map the checkbox's checked/unchecked state to valid boolean values Camunda understands.

2. Convert the Value via a Task Submit Listener

If you can't modify the form directly (or prefer handling the conversion server-side), add a submit listener to your user task in Camunda Modeler:

  1. Open your user task's properties panel.
  2. Navigate to the Listeners tab, add a new listener with the event type submit.
  3. Select Script as the listener type, pick Groovy (or your preferred scripting language), and add this code:
def variableValue = execution.getVariable("problemVariableName")
// Replace "problemVariableName" with the actual variable triggering the error
if (variableValue == "on") {
    execution.setVariable("problemVariableName", true)
} else {
    execution.setVariable("problemVariableName", false)
}

Quick Check for Your Code

Looking at your truncated form snippet, the <a> download link shouldn't be the culprit here. Double-check any other form elements (like hidden inputs or checkboxes) that might be linked to a boolean variable in your process—this is where the mismatched type is likely coming from.

内容的提问来源于stack exchange,提问作者CodingGirl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:07:51