Unable to assign multiple checkbox selected values to a CDT

I have a CDT "AT_employeelanguages"

like below-attached screen

I am pulling the below table data using an expression and referring to the same using an expression rule AT_GetLanguages()

When I use the below code, nothing is saved into my CDT "employeelanguages". Can someone guide me to solve this issue? Thanks in advance.

a!localVariables(
local!languages: rule!AT_GetLanguages(),
local!selectedLanguages,
a!formLayout(
label: "Test" & local!selectedLanguages,
contents: {
a!checkboxField(
label: "Languages Known",
choiceLabels: index(local!languages, "name", null),
choiceValues: index(local!languages, "languagenumber", null),
value: local!selectedLanguages,
saveInto: {
local!selectedLanguages,
a!save(
ri!employeelanguages,
local!selectedLanguages
)
}

)
}
)

  Discussion posts and replies are publicly visible

  • local!selectedLanguages is just the language number so you're trying to save a list of integer into a CDT without telling the save WHERE in the CDT you want to save it (as in, what field).

    I'd do it like this:

    a!localVariables(
      local!languages: {
        {
          languagenumber: 1,
          name: "English"
        },
        {
          languagenumber: 2,
          name: "Spanish"
        },
        {
          languagenumber: 3,
          name: "Telugu"
        }
      },
      local!selectedLanguages,
      local!employeelanguages, /*Using a local variable rather than rule input so that the code works when copy pasting*/
      a!formLayout(
        label: "Test" & index(
          local!employeelanguages,
          "languagenumber",
          {}
        ),
        contents: {
          a!checkboxField(
            label: "Languages Known",
            choiceLabels: index(local!languages, "name", null),
            choiceValues: index(local!languages, "languagenumber", null),
            value: index(
              local!employeelanguages,
              "languagenumber",
              {}
            ),
            saveInto: {
              local!selectedLanguages,
              a!save(
                target: local!employeelanguages,
                value: a!forEach(
                  items: local!selectedLanguages,
                  expression: {
                    languageid: null,
                    employeeid: loggedInUser(),
                    languagenumber: fv!item
                  }
                )
              )
            }
          ),
          a!paragraphField(
            value: local!employeelanguages
          )
        }
      )
    )