Is there a way to delete related records from a custom module upon deleting a parent record ?

Is there a way to delete related records from a custom module upon deleting a parent record ?

Hello, 

Is there a way of deleting records in a custom module in CRM through a custom deluge function, when the initial record is deleted ? 

Let's say I have a record A in the Potential module. When he's deleted, I want to delete records B and C which are linked to record A but exists in another custom module. I tried to create a workflow rule that triggers upon suppression, to execute a deluge code. 

The code should be like this : 

voidTLxCMxC_Cleaner(Int IdCommande) { 
TLxCMxC = zoho.crm.getRelatedRecords("TLxCMxC","Deals",IdCommande);
Statut = TLxCMxC.get("Stage");
for each  Recherche in TLxCMxC
{
ID = Recherche.get("id");
deleteResp = zoho.crm.invokeConnector("crm.delete",{"module":"TLxCMxC","id":ID});
info deleteResp;
}

}


This deluge code works completely fine when I'm testing it with a Deal that hasn't been deleted, but whenever I try to test it for real and to trigger the workflow by deleting my Deal, I get errors because since the deal has been deleted, Zoho crm can not find Related records in any other modules. 


So is there a way to solve this issue ?