Deleting subform data with "Delete Record" task...

Deleting subform data with "Delete Record" task...

Hi All!

I have used the "delete record" task many times by now and everything seems to be working fine.

But I have encountered a problem on this spot:

When this form is successfully submitted with an ID, I need to delete the record with that ID from a specific form.
So far so good.
But this form has subforms, so I need to manually delete their records too.


I have tried the following:

if (input.Form_Name  ==  "Insurance01")
{
    delete from Insurance_Sub[ ID == input.Rec_ID ];
    Project_Name_Here = Insurance_Sub[ID == input.Rec_ID].Project_Name;
    Ship_Name_Here = Insurance_Sub[ID == input.Rec_ID].Ship_Name;
    Ins_Type = Insurance_Sub[ID == input.Rec_ID].Insurance_Type;
    Internal_ID_Sub = Insurance_Sub[ID == input.Rec_ID].Internal_ID;
    Broker_ID_List = (Sub_Insurance_Broker[(((Project_Name == Project_Name_Here && Ship_Name == Ship_Name_Here) && Insurance_Type == Ins_Type) && Internal_ID == Internal_ID_Sub)].ID).getall();
    Security_ID_List = (Sub_Insurance_Security[(((Project_Name == Project_Name_Here && Ship_Name == Ship_Name_Here) && Insurance_Type == Ins_Type) && Internal_ID == Internal_ID_Sub)].ID).getall();
    for each Each_Broker_ID in Broker_ID_List
    {
        Current_ID = Each_Broker_ID.toLong();
        delete from Sub_Insurance_Broker[ ID == Current_ID ];
    }
    for each Each_Security_ID in Security_ID_List
    {
        Current_ID = Each_Security_ID.toLong();
        delete from Sub_Insurance_Security[ ID == Current_ID ];
    }
}

and also this:

if (input.Form_Name  ==  "Insurance01")
{
    delete from Insurance_Sub[ ID == input.Rec_ID ];
    Project_Name_Here = Insurance_Sub[ID == input.Rec_ID].Project_Name;
    Ship_Name_Here = Insurance_Sub[ID == input.Rec_ID].Ship_Name;
    Ins_Type = Insurance_Sub[ID == input.Rec_ID].Insurance_Type;
    Internal_ID_Sub = Insurance_Sub[ID == input.Rec_ID].Internal_ID;

            delete from Sub_Insurance_Broker[ Project_Name == Project_Name_Here && Ship_Name == Ship_Name_Here) && Insurance_Type == Ins_Type) && Internal_ID == Internal_ID_Sub ];
    
        delete from Sub_Insurance_Security[ (((Project_Name == Project_Name_Here && Ship_Name == Ship_Name_Here) && Insurance_Type == Ins_Type) && Internal_ID == Internal_ID_Sub) ];
    
}


but without success.

What am I missing here?

Thank you!

Ravid