How do I delete child records in Deluge?

How do I delete child records in Deluge?

I'm trying to use the sample code at https://www.zoho.com/deluge/help/data-access/delete-records.html to delete child records when the parent is deleted. The parent module is System_Summary and the child module is System_Summary. Here is my code:

subforms_ids = System_Summary[ID == input.ID].System_Event; 
for each sub in subforms_ids 
delete from System_Event[ID == sub]; 
}

When I try to save this, I get this error message:

Failed to save the function
  • Syntax error. Expecting expression,invokeurl task or 'invokeintegration'. Found '['. Line Number: 1

I'm not sure how to interpret that error. What am I doing wrong in my script?

I created this script as follows:
  1. Go to Workflow Rules
  2. Create a Rule
  3. Select the System Summaries module
  4. Set the rule to execute on Record Action
  5. Select "Delete"
  6. Click Next
  7. Apply the rule to All System Summaries
  8. Click Next
  9. Select Function
  10. Select Write Your Own
  11. Fill in the Create New Function form and click Create