Zoho Invoice custom function for Estimate module

Zoho Invoice custom function for Estimate module

Hi!
I using invoice.zoho.
I want to update "quantity" after push custom fields (Ex: NightQty and Qly): 
  1. quantity = NightQty * Qly
I created a custom function for Estimate module in Custom functions tab:
  1. estimateID = estimate.get("estimate_id");
  2. organizationID = organization.get("organization_id");
  3. estimateMap = zoho.books.getRecordsByID("Estimates",organizationID,estimateID).get("estimate").toMap();
  4. itemJSON = estimateMap.get("line_items").toList();
  5. updatedLineItems = List();
  6. for each  item in itemJSON
  7. {
  8. item_CFs = item.get("item_custom_fields").toList();
  9. updatedLineItem = Map();
  10. updatedLineItem.put("line_item_id",item.get("line_item_id"));
  11. nights = 0;
  12. roomqty = 0;
  13. for each  item_cf in item_CFs
  14. {
  15. if(item_cf.get("label").equalsIgnoreCase("NightQly"))
  16. {
  17. nights = item_cf.get("value").toDecimal();
  18. }
  19. else if(item_cf.get("label").equalsIgnoreCase("Qly"))
  20. {
  21. roomqty = item_cf.get("value").toDecimal();
  22. }
  23. }
  24. qty = nights * roomqty;
  25. updatedLineItem.put("quantity",qty);
  26. updatedLineItems.add(updatedLineItem);
  27. }
  28. json = Map();
  29. json.put("line_items",updatedLineItems);
  30. response = zoho.books.updateRecord("Estimates",organizationID,estimateID,json);
  31. info response.get("message");
And I added to "Workflow Rules". But this function not working and I receive error:  Custom Function Estimate failed to execute for the workflow Update Estimate.  
This code worked on Invoice module with "zoho intergration" like "zoho.invoice.getRecordByID()" and "zoho.invoice.update()".
Can help me?
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方