VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Boolean Form Submission Error in Business Forms Panel 4.8.0 with Grafana 11.1.0 - Form Element: Radio group with boolean options #552

Open m4v3rickmts opened 1 week ago

m4v3rickmts commented 1 week ago

Git Issue: Boolean Form Submission Error in Business Forms Panel 4.8.0 with Grafana 11.1.0

Summary

When using the Business Forms Panel (v4.8.0) in Grafana (v11.1.0), submitting a boolean field with a value of false results in an error. This issue arises due to the undefined value being sent in the update statement for false.

Steps to Reproduce

  1. Set up a Grafana dashboard with:
    • Two form panels for numeric inputs.
    • One form panel using a "Radio group with boolean options".
  2. Connect the form panels to a PostgreSQL database.
  3. Ensure the database field for the boolean is initially set to false.
  4. Perform the following actions:
    • Set the boolean form to true and submit: ✅ Submission succeeds.
    • Set the boolean form to false and submit: ❌ Submission fails.

Observed Behavior

Expected Behavior

Environment

Additional Notes

The issue seems to originate from how the form panel processes and serializes boolean values during submission. The discrepancy between the "Update Confirmation Window" and the actual update statement may offer a clue.

Request

Can this behavior be verified and addressed? If additional debugging or testing is needed, please provide guidance.

Thanks

mikhail-vl commented 6 days ago

@m4v3rickmts Do you create payload using custom code with if statement? If yes, please remove it to send element's values as is.

m4v3rickmts commented 4 days ago

@mikhail-vl I set the "Custom Code" (Initial Request) field to empty but still the same issue. I tried it with both "Custom Code" fields but the error with "undefined" won't be solved.

Any ideas?

mikhail-vl commented 4 days ago

@m4v3rickmts I will try to reproduce and get back to you.

m4v3rickmts commented 3 days ago

Meanwhile I am using a workaround: isactive=case when '${payload.isactive}'='true' then true else false end

I check if it is true and update the table with true, else with false. But I am sure it would be much more convenient if the radio group return was either true or false.