variable just bring me a value on user input action

variable just bring me a value on user input action

Hello, i try to find the error in this code, but i give up..

i have this in a user input action:

sum = 0;

for each s in input.invoices
{
    search_invoices_mount  =  Ingreso_de_Facturas  [dato == s];
    sum = (sum  +  ceil(search_invoices_mount.Monto_total_US));

}
traeinfocanal  =  Ingreso_de_Clientes  [Canal == input.Cliente];
traeinfocanal.Cartera = (traeinfocanal.Cartera  -  suma);

works fine, but if i cut and paste this in form action, on success, dont work, show me the log

Error evaluating NUMERIC expression : Unable to perform the operation - over the operand null and 1,744

i dont know why is null when try on success action..