Can someone please explain why this function is not working?

Can someone please explain why this function is not working?

This worked previously, but suddenly stopped. i can't figure out why

it is the exact same script that we use on two other fields. but for some reason it won't work on this field

What it does is grab the total money owed for a certain product type and puts the total in a certain field in the quote.

This code is the working code:

  1. qrecs = zoho.crm.getRecordById("Quotes",qid.toLong());
  2. //info qrecs ;
  3. pds = ifnull(qrecs.getJSON("Product_Details"),List());
  4. mrp = ifnull(qrecs.getJSON("Monthly_Recurring_Price"),1);
  5. tot = 0;
  6. for each  pd in pds
  7. {
  8. pid = ifnull(ifnull(pd.getJSON("product"),Map()).getJSON("id"),"");
  9. if(pid.toString().len() > 0)
  10. {
  11. prec = zoho.crm.getRecordById("Products",pid.toLong());
  12. //info prec ;
  13. if(ifnull(prec.getJSON("Product_type"),"") == "Monthly Recurring")
  14. {
  15. tot = tot + ifnull(pd.getJSON("net_total"),0);
  16. info tot;
  17. }
  18. }
  19. }
  20. //if(tot == mrp || tot == 1)
  21. //{
  22. mp = Map();
  23. mp.put("Monthly_Recurring_Price",tot);
  24. qupr = zoho.crm.updateRecord("Quotes",qid.toLong(),mp);
  25. info mp;
  26. info qupr;
The above code works perfectly

but when I use this code, it always outputs 0

  1. qrecs = zoho.crm.getRecordById("Quotes",qid.toLong());
  2. //info qrecs ;
  3. pds = ifnull(qrecs.getJSON("Product_Details"),List());
  4. mrp = ifnull(qrecs.getJSON("PartnerMonthlyTotal"),1);
  5. tot = 0;
  6. for each  pd in pds
  7. {
  8. pid = ifnull(ifnull(pd.getJSON("product"),Map()).getJSON("id"),"");
  9. if(pid.toString().len() > 0)
  10. {
  11. prec = zoho.crm.getRecordById("Products",pid.toLong());
  12. //info prec ;
  13. if(ifnull(prec.getJSON("Product_type"),"") == "Monthly Recurring")
  14. {
  15. tot = tot + ifnull(pd.getJSON("Partner_Total"),0);
  16. info tot;
  17. }
  18. }
  19. }
  20. //if(tot == mrp || tot == 1)
  21. //{
  22. mp = Map();
  23. mp.put("PartnerMonthlyTotal",tot);
  24. qupr = zoho.crm.updateRecord("Quotes",qid.toLong(),mp);
  25. info mp;
  26. info qupr;
  27. //}
All the API names are correct, I get no errors when I test the script. it just always outputs zero