function error - consolidate records by field for pushing to CRM

function error - consolidate records by field for pushing to CRM

I'm writing a function to update products quantity in Zoho CRM.  within my creator products form i have multiple products with the same name, so I want to sum the totals up for those products and then pass them onto CRM.  However, while writing a function there seems to be one line that seems to cause me problems throwing the error on compile:
Error at line number : 4 
Not able to find 'sum' function" ;

  1. fetchData = formName[ field == function_variable].sum(fetchData.fieldINform);
the function passes in the function variable. 

for reference the entire function:

  1. void crmRecord.updateStock(string stockName)
  2. {
  3.         //consolidating data and creating map to push to CRM
  4.         fetchData = Products [ Product_Name == stockName ].sum(fetchData.Available_Stock);
  5.         //creating map for CRM
  6. myFieldMap = Map();
  7. myFieldMap.put("Qty in Stock",fetchData);
  8. //sending to CRM
  9. crmResp = zoho.crm.updateRecord("Products","2262025000000134003",myFieldMap);
  10. }