open-forms icon indicating copy to clipboard operation
open-forms copied to clipboard

Logic triggers with boolean variables don't work correctly

Open sergei-maertens opened this issue 2 months ago • 1 comments

Product versie / Product version

latest (fdb19fdd6625e0281bdaed4a39a90f4f9150ec26)

Omschrijf het probleem / Describe the bug

When I use a simple logic rule and use a boolean variable (checkbox component, boolean user defined variable...) as a trigger, this rule is not correctly serialized to JSON.

The resulting expression is:

{
  "==": [
    {
      "var": "kanAfvalOphalen"
    },
    "true"
  ]
}

and it should be:

{
  "==": [
    {
      "var": "kanAfvalOphalen"
    },
    true
  ]
}

UI representation:

image

The workaround is to use advanced logic instead of simple logic.

Stappen om te reproduceren / Steps to reproduce

  1. Add user defined variable foo with data type boolean
  2. Add a simple logic rule
  3. Select the variable foo in the "Als" dropdown
  4. Select de operation "is gelijk aan"
  5. Select "de waarde"
  6. Select the comparison value "Ja"
  7. Now, click the cog icon and click "Toon/verberg DSL weergave"

Any actions associated with this rule don't execute (for both true/false cases) because a string will never be equal to a boolean.

Verwacht gedrag / Expected behavior

Selecting Yes/No in the dropdown configures an actual boolean in the JSON logic expression, and my actions execute properly.

Screen resolution

None

Device

None

OS

None

Browser

Chrome

sergei-maertens avatar May 10 '24 10:05 sergei-maertens