Soft delete records

This is the structure I have:

Sheet Names (4 total):

criancas

pais

config

contexto

Column Names by Sheet:

Sheet 1: “criancas” (132 rows, 14 columns)

id_crianca

id_familia

nome

data_nasc

sexo

endereco

assistida

observacoes

foto_crianca

excluido

criado_por

data_criacao

modificado_por

data_modificacao

Sheet 2: “pais” (97 rows, 11 columns)

id_pais

id_familia

nome

tipo

telefone

observacoes

excluido

criado_por

data_criacao

modificado_por

data_modificacao

Sheet 3: “config” (2 rows, 4 columns)

id_config

relatorio_tipo

data_execucao

arquivo_pdf

Sheet 4: “contexto” (1 rows, 2 columns)

id

id_familia_selecionada

In AppSheet, when I delete a child from the criancas table (e.g., id_crianca = C001 and id_familia = F001), I need a way to:

Display the siblings (other children in the criancas table with the same id_familia) and their guardians from the pais table (also sharing the same id_familia), so the user can choose to delete all if desired.

However, it may be that only one child is leaving Afago because they’ve aged out of the program, while their siblings remain.

Alternatively, the entire family may be relocating to another city, in which case all family members should be removed.

I don’t actually want to delete any records from any table.

Instead, I want the column excluido to be marked as “sim” so that the record is hidden from the user.

Here’s the intended process:

1\. The user opens the app and is on the main View, which shows the list of children (sourced from the slice criancas_ativas, where excluido = "não").  2\. The user searches for and finds the child they wish to “delete”.  3\. The user clicks on the child’s name and is taken to the criancas_ativas_Detail view.  4\. At this point, they should see a button labeled “Excluir” that will execute the desired actions. When the user clicks this button: 

4.1 The id_crianca of the selected child is retrieved, and their id_familia is identified.

4.2 A View is shown displaying all members of the family (id_familia) from both the criancas and pais tables. This View should have the excluido column enabled for quick edit, allowing the user to choose which members to “delete” (in our case, perform a soft delete by hiding the rows from the app).

I tried many different approaches without success. So, I decided to ask for help from more experienced developers.
Your help is much appreciated!
Thanks.

Gemini’s interpretation of your request:

To clarify your request, you’re looking for an AppSheet workflow to “soft delete” records from two tables, criancas and pais, based on a user’s action. The goal is not to permanently remove data but to hide it by updating the excluido column.

Here’s a breakdown of the process you want to achieve:

1. The User Interface

  • A user navigates to a Detail View for a specific child in the criancas table. This view should only show active children, meaning the records have excluido = "não".
  • On this Detail View, there will be an “Excluir” (Delete) button.

2. The Deletion Workflow

When the user clicks the “Excluir” button, the app should perform the following actions:

  • It should identify the id_familia of the selected child.
  • The user should be presented with a new view or form. This view needs to display all family members (both children from the criancas table and parents from the pais table) who share the same id_familia.
  • Crucially, this view must allow the user to selectively update the excluido column for each family member. This way, they can choose to hide only the selected child, certain siblings, or the entire family.
  • After the user makes their selections, the records’ excluido column should be updated to "sim". The records are not actually deleted, just hidden from the main app views.

Your core problem is figuring out how to build this “selection view” and the subsequent update action in AppSheet. You’ve correctly identified that this requires a specific AppSheet workflow, possibly involving a combination of actions, views, and maybe a temporary “staging” table to hold the selections before committing them.

1 Like

Yes, that’s basically it.

The idea is clear and seems easy to accomplish, but I’m new to AppSheet and despite having tried many different approaches I can’t make it work…

2 Likes

Add a normal column to contexto named criancas, of type EnumList of Ref to criancas, and Valid if that includes only family members.

Add a similar column to contexto for pais.

When the user clicks Excluir, navigate them to a contexto form view. When the form is saved, perform a grouped action that updates the selected criancas and pais table rows.

1 Like

Thanks Steve.
I followed your advice and used ChatGPT to expand and details a step-by-step guide… to no avail!
After many hours! I can’t find a way to pass the id_familia from table criancas to the table contexto.
The AI is running in circles and suggesting the same things that lead to errors…
I’m baffled !

The Excluir action should be of type App: go to another view within his app with a Target expression like LINKTOFORM("contexto_Form", "id_familia", [id_familia]).

Rather than spending so much time fighting with ChatGPT, consider reading the documentation and learning how to do it yourself.

3 Likes

I think, I’m almost there…

On the left I click on a child and I get see the detail View of her information, along with an inline view of her siblings and parents (or guardians).

In the View Criancas_Detail I show the all the fields from the child that the user chooses, clicking on it. The two fields (Related pais and Related irmãos) automatically open the inline Views: pais_Inline and irmaos_Inline.
Question: how do I control which view those field open as inline view?

Is it possible to have the same View, but with the indicated fields EDITABLE so that the user can toggle “excluido” from “No” to “Yes” (this is my Soft Delete).

In the pais_Inline and irmaos_Inline system-generated view configurations.

Not directly. Instead, you could create an action that directly toggles the column’s value and either a) make that action the Row Selected event action for the _Inline view; or 2) attach that action to the inline position of a column and include that column in the _Inline view. Either of these options would change excluido immediately rather than later when the user saves (in fact, no save would be needed).

2 Likes

hi, an idea

Thanks Steve. I’m satisfied with what I got now.

Case closed!

2 Likes