Delete data types related to another via backend

Hi all, I’ve been struggling with this problem all week.
How to delete the whole data type (Tasks) with its children (title, description, related company, due date, task status, assignee) upon deleting a Company, which is another data type, using a backend trigger workflow?

My database is structured in a way that every Company has a data field called related tasks and each data type Task has a data field called related company.

I’ve tried a couple solutions using firstly a data type named Data Mapping and, secondly, using the Task data type, as you can see bellow:

Test 01:

  • Trigger - watch out for when a Company is deleted.
    • Data type for the trigger: Company
    • Data field for the steps: Data Mapping

image

Steps:

image

RESULTS: Didn’t work. It only deleted the related company field on the data type Data Mapping, related Data Mapping continued to exist.


Test 02:

  • Trigger - watch out for when a Company is deleted.
    • Data type for the trigger: Company
    • Data field for the steps: Data Mapping

image

Steps:

RESULTS: Didn’t work. Same as above. It only deleted the related company field on the data type Data Mapping, related Data Mapping continued to exist.


Test 03:

  • Trigger - delete the field related company on a given Task (when related company before was not empty and related company now is empty):
    • Data type for the trigger: Tasks
    • Data field for the steps: related company

image

Unable to build the expression just using Task before change’s related company, so I tried Search for Tasks whose related company = Task before change’s related company

RESULTS: Didn’t work.


Test 04:

  • Trigger - a Company is deleted (when related company before was not empty and related company now is empty):
    • Data type for the trigger: Company
    • Data field for the steps: Tasks

image

Steps - I’ve removed the Only when condition:
image

RESULTS: Didn’t work. It only deleted the related company field on the data type Task, related Task continued to exist.


Test 05:

  • Trigger - a Company is deleted (when related company before was not empty and related company now is empty):
    • Data type for the trigger: Company
    • Data field for the steps: Tasks

image

Steps:

RESULTS: Didn’t work. It only deleted the related company field on the data type Task, related Task continued to exist.

Please, help. Any thoughts?

Update. Solved using the following tutorial:
Café com Dave - A forma correta de deletar registros do seu Aplicativo - YouTube