error

Hi all, I am getting error as "Interface Definition: Expression evaluation error at function a!forEach [line 52]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!checkboxField [line 88]: A checkbox component [label=“”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was 1 and choiceValues was 1."  

even though given same as choiceValues as value,Can Someone suggest me on this?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • is it possible for one checkbox to have two or more values?

  • 0
    Certified Lead Developer
    in reply to JS0001

    No - each individual checkbox (i.e. each option in any given CheckboxField) represents exactly one ChoiceValue.  Guessing by your initial code (particularly the way your choiceLabels and choiceValues don't really line up logically) it looks like you're not really using it correctly.

  • yes but thanks for your suggestion. I want  that checkbox (only yes),based on that checkbox selection .scenario: once checkbox is selected as yes it should be disabled and if it not selected it should be available to select,but it has to be as per row. That is why I am trying to use that above code. Can suggest on this?

  • 0
    Certified Lead Developer
    in reply to JS0001

    I'm not sure I understand the use case you're describing.  Are you saying that each row will have a grid cell where the only thing displayed is a single checkbox, with the label of "yes", and if a user checks it, it becomes disabled (such that they can never un-select it)?

    First, is there any particular reason you don't just use the editable grid's built-in row selection mechanism for this?  It's essentially like an individual checkbox per grid row (though with no label and always in the furthest-left column).  But all other aspects of the behavior you're describing, could be attained by this functionality.

    But in any case you should be able to make it work with an independent checkbox like you're doing now, if you correct your setup.

    The main thing wrong is that you're setting "choiceValues" to the current value of the row item:

    This is not how choiceValues works.  choiceValues should be the array of values matching the array of labels.  If you want only one checkbox, then choiceLabels would be an array like {"Yes"}, and choiceValues would be an array like {true()}.  You would never mention the current actual value in choiceValues - which is what you're currently doing.

  • Yes,As you mentioned I have used editable grid but,need check box for the particular column like (utilisation),once user clicks,As like mentioned above functionality.But data has to come from the database (i.e utilisation column),but as per your suggestion I could give choice value and label,if i try to give value smtg it is throwing an error.

  • 0
    Certified Lead Developer
    in reply to JS0001
    if i try to give value smtg

    Can you clarify what you mean by this?  Please post an updated code example and a screenshot of what error message you're getting.

  • 0
    Certified Lead Developer
    in reply to JS0001

    Hi,

    As Mike mentioned your choicelValues configuration is not right. But if you are trying to query something when user selects check box and save that value to that column see that attached sample code which might help you.

    a!localVariables(
      local!yourCDT: {
        a!map( id: 1, checkboxColumn: null , lastName: null ),
        
      },
      a!formLayout(
        label: "Example: Add,Update, or Remove Employee Data",
        contents: {
          a!gridLayout(
            totalCount: count(local!yourCDT),
            headerCells: {
              a!gridLayoutHeaderCell(label: "Check Box" ),
              a!gridLayoutHeaderCell(label: "Last Name" ),
              a!gridLayoutHeaderCell(label: "" )
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
              a!gridLayoutColumnConfig(width: "ICON")
            },
            rows: a!forEach(
              items: local!yourCDT,
              expression: a!gridRowLayout(
                contents: {
                  a!localVariables(
                    local!checkBoxValue: fv!item.checkboxColumn,
                    a!checkboxField(
                      label: "check box lable " & fv!index,
                      choiceLabels: { "Yes" },
                      choiceValues: { 1 },
                      value: local!checkBoxValue,
                      saveInto: {
                        local!checkBoxValue,
                        /*if you want to query and something from DB and save that value that check box value */
                        /*when user selects check box quet your DB here*/
                        a!save(
                          fv!item.checkboxColumn,
                          /*yor query result*/
                        ),
                        /*or if you want to save your result directly*/
                        fv!item.checkboxColumn
                      },
                      required:true
                    )
                  ),
                  a!textField(
                    label: "last name " & fv!index,
                    value: fv!item.lastName,
                    saveInto: fv!item.lastName,
                    required:true
                  ),
                  a!richTextDisplayField(
                    value: a!richTextIcon(
                      icon: "close",
                      altText: "delete " & fv!index,
                      caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          a!save(local!yourCDT, remove(local!yourCDT, save!value))
                        }
                      ),
                      linkStyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  )
                },
                id: fv!index
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Row",
              value: {
              },
              saveInto: {
                a!save(local!yourCDT, append(local!yourCDT, save!value))
              }
            ),
            rowHeader: 1
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            submit: true
          )
        )
      )
    )

  • This is exactly the same thing which I need to develop, But one issue is in cdt for checkboxcolumn instead of null there is value 0 which was previously inserted. that's why i was getting those error message. Can you help me with these?