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:
- qrecs = zoho.crm.getRecordById("Quotes",qid.toLong());
- //info qrecs ;
- pds = ifnull(qrecs.getJSON("Product_Details"),List());
- mrp = ifnull(qrecs.getJSON("Monthly_Recurring_Price"),1);
- tot = 0;
- for each pd in pds
- {
- pid = ifnull(ifnull(pd.getJSON("product"),Map()).getJSON("id"),"");
- if(pid.toString().len() > 0)
- {
- prec = zoho.crm.getRecordById("Products",pid.toLong());
- //info prec ;
- if(ifnull(prec.getJSON("Product_type"),"") == "Monthly Recurring")
- {
- tot = tot + ifnull(pd.getJSON("net_total"),0);
- info tot;
- }
- }
- }
- //if(tot == mrp || tot == 1)
- //{
- mp = Map();
- mp.put("Monthly_Recurring_Price",tot);
- qupr = zoho.crm.updateRecord("Quotes",qid.toLong(),mp);
- info mp;
- info qupr;
The above code works perfectly
but when I use this code, it always outputs 0
- qrecs = zoho.crm.getRecordById("Quotes",qid.toLong());
- //info qrecs ;
- pds = ifnull(qrecs.getJSON("Product_Details"),List());
- mrp = ifnull(qrecs.getJSON("PartnerMonthlyTotal"),1);
- tot = 0;
- for each pd in pds
- {
- pid = ifnull(ifnull(pd.getJSON("product"),Map()).getJSON("id"),"");
- if(pid.toString().len() > 0)
- {
- prec = zoho.crm.getRecordById("Products",pid.toLong());
- //info prec ;
- if(ifnull(prec.getJSON("Product_type"),"") == "Monthly Recurring")
- {
- tot = tot + ifnull(pd.getJSON("Partner_Total"),0);
- info tot;
- }
- }
- }
- //if(tot == mrp || tot == 1)
- //{
- mp = Map();
- mp.put("PartnerMonthlyTotal",tot);
- qupr = zoho.crm.updateRecord("Quotes",qid.toLong(),mp);
- info mp;
- info qupr;
- //}
All the API names are correct, I get no errors when I test the script. it just always outputs zero