Sending Info to Custom Module Using Function

Sending Info to Custom Module Using Function

Hi, 

I have set up a custom module called "Entities" in Zoho CRM. Each Entity record can be linked to several Product Records. 

I want to write a function which will sum the "Amount" fields from every Product record associated with the Entity and then update the "Total Entity MRR" field in the Entity Record with the total. I have already written a function which does a similar thing with Accounts and Products which works well, but I can't seem to get it to work with Entities. This is the code I have so far: 

resp = zoho.crm.getRelatedRecords("Products","Entities",EntityId.toLong());
//info resp;
total = 0.0;
for each  rec in resp
{
total = total + ifnull(rec.get("Amount"),"0.0").toDecimal();
}
info total;
updateResp = zoho.crm.updateRecord("Entities",EntityId.toLong(),{"Total_Entity_MRR":total});
info updateResp;

Would someone be able to assist with this? 

    Access your files securely from anywhere

        Zoho Developer Community




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


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now