Add row in table B, after delete row in table A

Hi everyone, I need you to help me with something. Step to comment.
From table A (detail), where the record of equipment associated with an order is saved. I give the possibility to delete a record from table A (detail). But I need to be able to create an action that executes when a record is dropped from table A (detail). This action must leave a record in table B (history) creating a row where data of the deleted record and the date of deletion are saved.
Is it possible to do this? I appreciate your help.

0 13 989
13 REPLIES 13

Yes, however you will need to create your own custom action(s) to delete. When you use the AppSheet native delete action, this effectively removes the row from the table immediately and is therefor not available to access for copying to another table. At least that is my experience, someone please correct me if I am wrong.

What I do for this situation is create a custom Grouped action. The first action within the group copies to your history/log table and the second action performs the delete. I may be oversimplifying as it could take more than two actions but you get the main idea I hope.

THANKS!!! do you have any example that can guide me?

That’s correct!

These are some articles that may help you:

You can go deeper from those articles.

yes, approach shared by @WillowMobileSystems would be work.
There should be bunch of other workaround as well.

For instance, dont involve the other table store the deleted record but use just a slice.

Create custom action to toggle the value for newly creating field value [Deleted?] from false to true. Initial value for this field is set to false, but once the user hit the delete action, it is actually not delete row from the table, but toggle the value to true. For the first slice is removing the row with value of true, then it only display the set of rows with value of false, which are not deleted explicitly by the users.
The second slice will be opposite, the deleted rows are only visible.

It is possible the user by mistake add the row, in that case, simply present the default action to delete the row.

Even for the second table for rows only delete? as true value, we can present action to toggle back to true, then move the product back to original order. This would flexiblity to the users to control.

Is it possible to do the following steps via grouped behaviour ?

  1. edit form of table B using values from table A record [link to form view]
  2. And if the Table B form is saved, delete table A record

if possible, how to do that… plz help

Not possible. A grouped action stops after the first navigation action.

Delete action and deeplink action within group actions is action killer.

It is not possible with a SINGLE Grouped action. However, you can accomplish the same thing by breaking it up.

One action that uses the LINKTOFORM() and copies Table A row values into Table B Form view.

Then a second action (or likely a Group) that is attached to the Form Save behavior of Table B Form view. This action would delete Table A row. This would require “remembering” somehow which Table A row to delete. I would probably include in Table B a hidden column named “Copied From” that saves the Table A row key value. If that column ISNOTBLANK(), then delete the Table A row by that row key. Then clear the column after delete.

Thanks,
But where to apply the ISNOTBLANK() expression, In the ‘delete this row’ action there is no place to put the expression.

In your case, if you were to use my suggestion, you would have Row B that contains the column “Copied From” - the Row A key. You would need to use, what I call a bridge action to transition from operating on Table B rows to operating on Table A rows. This bridge is accomplished with the action of type “Data: execute an action on a set of rows”. This action type lets you specify another table source, action and set of rows.

So here is what you would do:

  1. Create an action and set the “For a record of this table” to Table B.
  2. Set the “Do this” type to “Data: execute an action on a set of rows”.
  3. Set the “Referenced Table” to Table A.
  4. Set the “Referenced Row” to LIST([Copied From]) - must be in list form.
  5. Set the “Referenced Action” to Delete - the system delete is just fine.
  6. In the Behavior section, set the “Only if this condition is true” to ISNOTBLANK([Copied From])

Now you will have an action that deletes the Table A row noted in the Copied From column in a Table B row.

I hope this helps!

Yes it worked…Thank you John Baer.
Appreciate your effort in explaining with detailed steps…
Thanks…

Ok, Thanks for the Information…

Top Labels in this Space