How to update or delete a record in Table

Hi,

Let’s say, you have a list of master data in a Table layout and you want to update some of the attributes in a record directly from the list (see below screenshot). Inline edit mode gives you the functionality to do so on UI, but it only updates data on memory, and it doesn’t persist to the database by itself. I’ve seen many developers create their own activity to manually save the changes in the database looping over the list. That is fine, but in this post I am sharing a little easier approach to do this. Be noted, in this example I will demonstrate it using Data Type but this method can be applied to any concrete class (Data-, Work-, or others).

  • Record update
  1. Define a Data Type. Then create a Report Definition or Data Page to retrieve all records from the database and configure a Table that sources it.

  1. In Operations tab, enable Inline Edit mode.

  1. In Advanced section, turn on the following checkboxes and fill in the out-of-the-box activities.
1 Run activity before grid update pzPreUpdateRecordWrapper
2 Run activity after grid update pzPostUpdateRecordWrapper

  1. That’s it. Now double click on any record in a Table and update some attributes. Click outside of the Table and system immediately saves the changes in the database for you. It adds a record in the history table as well.

  • Record delete
  1. Add one more column in the Table and configure a Delete item icon.

  1. For On-click event, add two actions - Delete Item and Refresh-This section.

  1. You may expect that it should be working by now, but unfortunately it isn’t. The reason for this is because, the out-of-the-box activity “pzPreUpdateRecordWrapper” step 2 is skipped. When condition is checking if the section name is “pzRecordEditor” or not.

  1. So I did Save As this activity and named it “PreUpdateRecordWrapper”. Remove above When condition (2nd row). Keep the class as @baseclass so you can reuse it for any class (Work-, Data-, and others).

  1. Specify this new activity for “Run activity before grid update” as below.

  1. That’s it. Now you can test it.
  • Notes

If the class has other dependent classes and you want to delete them in sync, you will have to manually clean them up. For example, if the list of Table is sourced in Link-Attachment class, Delete icon will only delete a record in Link-Attachment class and system won’t delete Data-WorkAttach-File class or Repository.

Thanks,

@KenshoTsuchihashi I tried it this worked. Thanks for sharing steps clearly.

@KenshoTsuchihashi ,thanks for the thorough explanation.

However I tried the first part (only editing a row) and somehow activity pzPostUpdateRecordWrapper does not run after leaving the row again, meaning it does not persist to the database. When double clicking on the row, I do see that besides the Pre activity it also runs activity pzPostUpdateRecordWrapper with param.pyGridAction = EDITROW. But leaving the table grid does not run this Post activity again. Do you know how this can happen? I suspect it has something to do with the action sets which are set on clicking on a row.

Thanks in advance!

@KenshoTsuchihashi

Any OOTB way to club using savable data pages to update, savable data pages to delete(In 8.8 even delete option is available in the save plan) in the above logic