Skip to main content
August 23, 2022
Solved

Store the values of a multipledropdownfield

  • August 23, 2022
  • 12 replies
  • 0 views

Help please 

I want to store a multipledropdownfield into my cloud database 

I add the multipledropdownfield, if i pick only value, it works great (see the image bellow)

If i pick or select TWO or more values, an ERROR appears (see the image bellow)

This is the expression of the multipleDropdownField

{
a!multipleDropdownField(
label: "Acceso a servicios basicos?",
labelPosition: "ABOVE",
placeholder: "--- Seleccione ---",
choiceLabels: {
"Agua",
"Luz",
"Teléfono",
"Internet"
},
choiceValues: {
"Agua",
"Luz",
"Teléfono",
"Internet"
},
value: ri!CWA_OECClient.coecaccesoservicionbasicos,
saveInto: ri!CWA_OECClient.coecaccesoservicionbasicos,
required: true,
validations: {}
)}

    Best answer by agamb0001

    Hi [mention:692ffbce4f9f4ab8a8d1a627320bbd5f:e9ed411860ed4f2ba0265705b8793d05]

    Use the below code: 

    {
      a!multipleDropdownField(
        label: "Acceso a servicios basicos?",
        labelPosition: "ABOVE",
        placeholder: "--- Seleccione ---",
        choiceLabels: { "Agua", "Luz", "Teléfono", "Internet" },
        choiceValues: { "Agua", "Luz", "Teléfono", "Internet" },
        value: if(
          a!isNullOrEmpty(
            ri!CWA_OECClient.coecaccesoservicionbasicos
          ),
          {},
          split(
            ri!CWA_OECClient.coecaccesoservicionbasicos,
            "; "
          )
        ),
        saveInto: ri!CWA_OECClient.coecaccesoservicionbasicos,
        required: true,
        validations: {}
      )
    }

    12 replies

    agamb0001
    August 23, 2022

    Hi @danna3499,

    It looks like the field ri!CWA_OECClient.coecaccesoservicionbasicos is of type text, hence it is storing multiple values into one text string like"Agua; Luz" and the drop-down expects a string array {"Agua", "Luz"}

    Try using split function in the value of the drop-down.and split on "; "

    I hope it resolves your issue 

    Like

    value: split(ri!CWA_OECClient.coecaccesoservicionbasicos, "; ")

    danna3499Author
    August 24, 2022

    i tried it, but doesn't work  [emoticon:ca08b2c27c2f40e993e89508acf29e0b]

    agamb0001
    agamb0001Answer
    August 24, 2022

    Hi [mention:692ffbce4f9f4ab8a8d1a627320bbd5f:e9ed411860ed4f2ba0265705b8793d05]

    Use the below code: 

    {
      a!multipleDropdownField(
        label: "Acceso a servicios basicos?",
        labelPosition: "ABOVE",
        placeholder: "--- Seleccione ---",
        choiceLabels: { "Agua", "Luz", "Teléfono", "Internet" },
        choiceValues: { "Agua", "Luz", "Teléfono", "Internet" },
        value: if(
          a!isNullOrEmpty(
            ri!CWA_OECClient.coecaccesoservicionbasicos
          ),
          {},
          split(
            ri!CWA_OECClient.coecaccesoservicionbasicos,
            "; "
          )
        ),
        saveInto: ri!CWA_OECClient.coecaccesoservicionbasicos,
        required: true,
        validations: {}
      )
    }

    August 24, 2022

    Try using the below code

    {
        a!multipleDropdownField(
          label: "Acceso a servicios basicos?",
          labelPosition: "ABOVE",
          placeholder: "--- Seleccione ---",
          choiceLabels: { "Agua", "Luz", "Teléfono", "Internet" },
          choiceValues: { "Agua", "Luz", "Teléfono", "Internet" },
          value: if(
            a!isNullOrEmpty(ri!CWA_OECClient.coecaccesoservicionbasicos),
            null,
            split(ri!CWA_OECClient.coecaccesoservicionbasicos, ";")
          ),
          saveInto: {
            ri!CWA_OECClient.coecaccesoservicionbasicos,
            a!save(ri!CWA_OECClient.coecaccesoservicionbasicos, joinarray(ri!CWA_OECClient.coecaccesoservicionbasicos, ";"))
          },
          required: true,
          validations: {}
        )
      }

    danna3499Author
    August 24, 2022

    i tried it, but doesn't work  [emoticon:ca08b2c27c2f40e993e89508acf29e0b][emoticon:ca08b2c27c2f40e993e89508acf29e0b]

    August 24, 2022

    Could you please show us the rule imput CDT