Problem in deleting a row in a gridRowLayout

Hi,

I have a grid row layout and added an remove icon at the end for each row.

When I click on remove icon, row is deleting from the UI but it is not deleting from the database.

I used the below code for removing the grid row from the UI

link: a!dynamicLink(
            value: ri!clickedRow,
            saveInto: {
              a!save(
                ri!data,
                remove(
                  ri!data,
                  ri!index
                )
              )
            }
          )

Could anyone please help me how to delete the row from the table through the interface

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    You need to save deleted row PK ids into a rule input and pass those values to process. In your process use delete data store entity smart service to delete those record using those IDs. 

    You can use below logic to save your deleted IDs

    link: a!dynamicLink(
      value: ri!clickedRow,
      saveInto: {
        if(
          a!isNullOrEmpty(fv!item.id),
          {},
          a!save(
            ri!deletedIds,
            append(
              ri!deletedIds,
              fv!item.id /*Primary Key of that row*/
            )
          )
        ),
        a!save(
          ri!data,
          remove(
            ri!data,
            ri!index
          )
        )
      }
    )

  • 0
    Certified Lead Developer

    FWIW, It's usually advised not to just delete a DB row like this (especially with "1-click" functionality from which there's no return); instead, you'd use more of a "deactivate" pattern where you have that row's dynamic link set a flag, like setting "is active" from TRUE to FALSE, or alternately, an "is deleted" flag from FALSE to TRUE.  After the task is submitted, the altered row is written to the DB and your future processing can account for deactivated and/or "soft deleted" rows.

  • Hi Naresh,

    Thanks for your response. I have used a!deleteFromDataStoreEntities in interface

    link: a!dynamicLink(
                value: ri!clickedRow,
                saveInto: {
                  a!save(
                    ri!data,
                    remove(
                      ri!data,
                      ri!index
                    )
                  ),
    			  a!deleteFromDataStoreEntities(
                      dataToDelete: {
                        entity: cons!CDT_Name, identifiers: ri!data[ri!index].Id
                      }
                    )
                }
              )


    But still it is not deleting from database. Could anyone please help me on this

  • 0
    Certified Lead Developer
    in reply to akhilag7167

    It is very difficult to understand what you are trying here. In your code your are using ri!index, what is this ri!index? how u get this value? are you trying to delete inside grid? or this deletion logic is outside of grid?