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 Desk Resources

                            • Desk Community Learning Series

                            • Digest

                            • Functions

                            • Meetups

                            • Kbase

                            • Resources

                            • Glossary

                            • Desk Marketplace

                            • MVP Corner

                            • Word of the Day

                                Zoho Marketing Automation

                                        Manage your brands on social media

                                                Zoho TeamInbox Resources

                                                  Zoho DataPrep Resources

                                                    Zoho CRM Plus Resources

                                                      Zoho Books Resources

                                                        Zoho Subscriptions Resources

                                                          Zoho Projects Resources

                                                            Zoho Sprints Resources

                                                              Qntrl Resources

                                                                Zoho Creator Resources

                                                                  Zoho WorkDrive Resources

                                                                    Zoho Campaigns Resources

                                                                      Zoho CRM Resources

                                                                      • CRM Community Learning Series

                                                                        CRM Community Learning Series

                                                                      • Tips


                                                                      • Functions


                                                                      • Meetups


                                                                      • Kbase


                                                                      • Resources


                                                                      • Digest


                                                                      • CRM Marketplace

                                                                        CRM Marketplace

                                                                      • MVP Corner

                                                                        MVP Corner

                                                                          Design. Discuss. Deliver.

                                                                          Create visually engaging stories with Zoho Show.

                                                                          Get Started Now