Help with script for custom action

Help with script for custom action

Hi, 

I have a custom action that works fine for the form's report it was created. In this main form (Requisici_n_de_Compra) there is a subform (Detalle_RC). I would like to have the same feature for the subform report.

this is the  script that currently works for the main form report.

void PostInv2(int PurchaseID)
{
    proRowData  =  Requisici_n_de_Compra  [ID == input.PurchaseID];
    for each r in proRowData.Detalle_RC
    {
        fet  =  Agregar_Producto_Almac_n  [Descripci_n == r.Descripci_n];
        fet.Stock = (ifnull(fet.Stock,0.0)  +  ifnull(r.Cantidad.toDecimal(),0.0));
        info fet.Stock + " " + r.Cantidad;
        thisapp.Inventario.InvReq(fet.ID);
    }
    proRowData.EstatusRC = "En Almacén";
}

I try changin the names accordingly how I think it may work but with no success, I get errors or I am not able to save the code.

Can someone please help me with some guidance on how should I change the code a little in order to make it work for the subform (Detalle_RC).

Any help will be appreciated