Skip to main content
February 4, 2025
Question

Selection save into not working in grid field

  • February 4, 2025
  • 3 replies
  • 0 views

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
    February 4, 2025

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

    February 4, 2025

    Any response for the above?

    amaans4178
    February 4, 2025

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