It's anyway to save true or false value in differents columns of database but in one unique checkboxfield?

Certified Associate Developer

Hi,

my trouble here is that I don't know how can I save true or false in differents boolean columns in my database. I tried something like that:

a!checkboxField(
                label: "",
                labelPosition: "ABOVE",
                choiceLabels: { "Limpieza","Plaga","Manipulador" },
                choiceValues: { "Limpieza","Plaga","Manipulador" },
                value: {if(isnull(fv!item.inLimpieza),{},"Limpieza"),if(isnull(fv!item.inPlaga),{},"Plaga"),if(isnull(fv!item.inManipulacion),{},"Manipulador")},
                saveInto:{
                  a!save(
                    fv!item.inLimpieza,
                    if(contains( save!value, "Limpieza" ), true,false)
                  ),
                  a!save(
                    fv!item.inPlaga,
                    if(contains( save!value, "Plaga" ), true, false)
                  ),
                  a!save(
                    fv!item.inManipulacion,
                    if(contains( save!value, "Manipulador" ), true, false)
                  ),
                },
                disabled: ri!readOnly,
                validations: {}
              ),

But It's not wortking correctly.

Actually, I have every data of every column in differents checkbox, but I would like to group all my checkbox in only one. Thanks for your help!

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    The issue you had is that you wrote true/false to the booleans, but checked for null in the value parameter. Make sure to prefill the boolean fields properly. A null-boolean is always a troublesome value. Made this working:

    a!localVariables(
      local!item: a!map(
        inLimpieza: false,
        inPlaga: false,
        inManipulacion: false
      ),
      a!checkboxField(
        choiceLabels: { "Limpieza","Plaga","Manipulador" },
        choiceValues: { "Limpieza","Plaga","Manipulador" },
        value: {
          if(local!item.inLimpieza, "Limpieza", {}),
          if(local!item.inPlaga, "Plaga", {}),
          if(local!item.inManipulacion, "Manipulador", {})
        },
        saveInto:{
          a!save(
            target: local!item.inLimpieza,
            value: contains( save!value, "Limpieza" )
          ),
          a!save(
            target: local!item.inPlaga,
            value: contains( save!value, "Plaga" )
          ),
          a!save(
            target: local!item.inManipulacion,
            value: contains( save!value, "Manipulador" )
          ),
        },
      )
    )

  • wrap your empty boolean in or() to make it return false every time it is null or false and true only when it is true. 

    Find documentation on how it works (point 7)- appianspace.com/.../

Reply Children
No Data