Saving checkbox values in editable grid

Hi Everyone,

I am facing an issue and I am not sure, What I am doing wrong.

Here is my datasubset 

{
{
record1: "21041001", 
nbr: "5DM874,C217668", 
recordname: {"test1", "test2"},
recordIds: {"75", "77"}, 
reportid: {}, 
selectedrecords: {}, 
selectedreports: {}, 
amount: 7.0,
recordamount: {15, 15}, 
reportamount: {}, 
trecordId: 76
},
{
{
record2: "21041100", 
nbr: "5DM874,C217668", 
recordname: {"test3", "test4"},
recordIds: {"78", "79"}, 
reportid: {}, 
selectedrecords: {}, 
selectedreports: {}, 
amount: 7.0,
recordamount: {15, 15}, 
reportamount: {}, 
trecordId: 88
}
}


I have an editable grid, which shows the record names in one of the column of grid from the above data subset and I ma trying to save the selected choices into "selectedrecords" parameter of above data subset using the following check box code.

a!checkboxField(
                    choiceLabels: fv!item.recordnames,
                    choiceValues: fv!item.recordnames,
                    value: fv!item.selectedrecords,
                    saveInto: {
                      fv!item.selectedrecords
                      
                    },
                    choiceLayout: "COMPACT"
)

I am getting the following error which is not helpful in understanding what I am doing wrong in saving the values to local variables.

Interface Definition: Expression evaluation error at function a!forEach [line 29]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!checkboxField [line 53]: Incorrect number of parameters for function; expected 2 parameters, but found 3 parameters.

  Discussion posts and replies are publicly visible

  • Hi, the main issue here is that the values such as recordname: {"78","79"} are actually being treated as a single value in some situations.  While the checkboxes will display the options properly, if you run a count() over the recordname, the result is 1.

    Without digging deep into the underlying datasubset structure as far as nested lists, etc, here is an option to save the values using a local!selections variable.  This assumes the record ID/Names are unique row by row (e.g., "79" does not appear in more than one row).  The idea is to save all selections into one variable, then when exiting the form we can apply these back into your data set - or do whatever else you need for processing.

    Feel free to expand on your use case from here. 

    a!localVariables(
      local!data: {
        {
          record: "21041001", 
          nbr: "5DM874,C217668", 
          recordname: {"test1", "test2"},
          recordIds: {"75", "77"}, 
          reportid: {}, 
          selectedrecords: null, 
          selectedreports: {}, 
          amount: 7.0,
          recordamount: {15, 15}, 
          reportamount: {}, 
          trecordId: 76
        },
        {
          record: "21041100", 
          nbr: "5DM874,C217668", 
          recordname: {"test3", "test4"},
          recordIds: {"78", "79"}, 
          reportid: {}, 
          selectedrecords: {}, 
          selectedreports: {}, 
          amount: 7.0,
          recordamount: {15, 15}, 
          reportamount: {}, 
          trecordId: 88
        }
      },
      local!selections,
      a!forEach(
        items: local!data,
        expression: a!localVariables(
          local!options: split(fv!item.recordname,"; "),
          a!checkboxField(
            choiceLabels: local!options,
            choiceValues: local!options,
            value: if(
              rule!APN_isEmpty(local!selections),
              null,
              intersection(local!options,local!selections)
            ),
            saveInto: {
              a!save(local!selections,reject(rule!APN_isEmpty,union(local!selections,save!value)))
            },
            choiceLayout: "COMPACT"
          )
        )
      )
    )