Selection save into not working in grid field

Hi, I am using a grid field and a rule input to save the selected rows, but all the selected row values are not saved in the rule input. Suppose I am selecting four rows only the value of 2 rows is saved in the rule input. When I select all the rows at once this is a problem. But if I select one row after other it doesn't create a problem.Attaching the code snippet for reference:

Any help in this regard will be appreciated.

  Discussion posts and replies are publicly visible

Parents
  • Hi, I don't understand why else condition logic would work according to you. 

    but here is the logic for your requirement, you can optimize it ->

         selectionSaveInto: {
              ri!selectedItems,
              a!save(
                local!currentSelectedRow,
                fv!selectedRows
              ),
              a!save(
                local!currentDeSelectedRow,
                fv!deselectedRows
              ),
              if(
                contains(
                  touniformstring(
                    property(
                      ri!selectedRow,
                     "id",
                      ""
                    )
                  ),
                  tostring(
                    property(
                      local!currentSelectedRow,
                      "id",
                      ""
                    )
                  )
                ),
                {},
                {
                  a!save(
                    ri!selectedRow,
                    append(ri!selectedRow, fv!selectedRows)
                  )
                }
              ),
              if(
                rule!CPPS_checkIsNull(local!currentDeSelectedRow),
                {},
                a!save(
                  ri!selectedRow,
                  remove(
                    ri!selectedRow,
                    wherecontains(
                      tostring(
                        index(
                          local!currentDeSelectedRow,
                          "id",
                          ""
                        )
                      ),
                      touniformstring(
                        index(
                          ri!selectedRow,
                         "id",
                          ""
                        )
                      )
                    )
                  )
                )
              ),
             
            },

Reply
  • Hi, I don't understand why else condition logic would work according to you. 

    but here is the logic for your requirement, you can optimize it ->

         selectionSaveInto: {
              ri!selectedItems,
              a!save(
                local!currentSelectedRow,
                fv!selectedRows
              ),
              a!save(
                local!currentDeSelectedRow,
                fv!deselectedRows
              ),
              if(
                contains(
                  touniformstring(
                    property(
                      ri!selectedRow,
                     "id",
                      ""
                    )
                  ),
                  tostring(
                    property(
                      local!currentSelectedRow,
                      "id",
                      ""
                    )
                  )
                ),
                {},
                {
                  a!save(
                    ri!selectedRow,
                    append(ri!selectedRow, fv!selectedRows)
                  )
                }
              ),
              if(
                rule!CPPS_checkIsNull(local!currentDeSelectedRow),
                {},
                a!save(
                  ri!selectedRow,
                  remove(
                    ri!selectedRow,
                    wherecontains(
                      tostring(
                        index(
                          local!currentDeSelectedRow,
                          "id",
                          ""
                        )
                      ),
                      touniformstring(
                        index(
                          ri!selectedRow,
                         "id",
                          ""
                        )
                      )
                    )
                  )
                )
              ),
             
            },

Children
No Data