Delete related records in custom function

Delete related records in custom function

Is there a way of deleting records in a custom module in CRM through a custom function? I cam across a post relating to doing it with the contacts table but have tried to replicate this with a custom table and it doesnt seem to work, or I have got something wrong in the function.

When a record is deleted in one custom module I want to select all related records in another custom module and delete them.

At the moment I have the following:

//
//Get all line items for the contract
resp = zoho.crm.searchRecords("custommodule1","(Contract ID|=|" + input.ContractID + ")");
//
//For each line item
for each rec in resp
{
varLineItemID=rec.get("custommodule1_ID");
linemap=map();
linemap.put("authtoken","XXXXXXXXXXXXX");
linemap.put("scope","crmapi");
linemap.put("id",varLineItemID);
//
info test;
}

If anyone can provide any suggestions, alternatives or help it would be much appreciated.

Thanks.