Trouble with custom function in zoho books

Trouble with custom function in zoho books

I am trying to use the below custom function, when retrieving "sub_total" it keeps returning "emtpy" however it works with "total" but I want to retrieve the sub total of the estimate.

crmpotid = estimate.get("zcrm_potential_id");
total = 0.0;
relest = zoho.books.getRecords("Estimates",801886364,"zcrm_potential_id").get("estimates");
for each rec in relest
esttotal = rec.get("sub_total").toDecimal();
total = total + esttotal;
mp = Map();
update = zoho.crm.updateRecord("Deals",crmpotid,mp);
info mp;
info update;
            Zoho Marketing Automation

                      Zoho Pagesense Resources

                        Zoho SalesIQ Resources

                              Zoho TeamInbox Resources

                                Zoho DataPrep Resources

                                  Zoho CRM Plus Resources

                                    Zoho Books Resources

                                      Zoho Subscriptions Resources

                                        Zoho Desk Resources

                                          Zoho Projects Resources

                                            Zoho Sprints Resources

                                              Qntrl Resources

                                                Zoho Creator Resources

                                                  Zoho WorkDrive Resources

                                                    Zoho Campaigns Resources

                                                      Zoho CRM Resources

                                                            Design. Discuss. Deliver.

                                                            Create visually engaging stories with Zoho Show.

                                                            Get Started Now