Skip to main content
Known Participant
Feb 4, 2025 9:17 AM UTC
Question

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.

    3 replies

    konduruc733182
    Inspiring
    Feb 4, 2025 10:49 AM UTC

    What is it supposed to do? More details on the requirement might help us understand the expression or what you have tried.

    Known Participant
    Feb 4, 2025 11:02 AM UTC

    Any response for the above?

    amaans4178
    Brainy
    Feb 4, 2025 11:56 AM UTC

    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",
                          ""
                        )
                      )
                    )
                  )
                )
              ),
             
            },