Subform loop not listing all records

Subform loop not listing all records

Hi,

We have a script that should transfer subform records from one module to another subform in another module, but it is only pulling the last record and looping it in the other module.

Please see script below and advise on how we can modify it to pull in and transfer all subform records.


  1. Deal = zoho.crm.getRecordById("Deals",DealID);
  2. //info Deal;
  3. //Deal subform data
  4. subform = Deal.get("Credit_References");
  5. data = Map();
  6. formlist = List();
  7. //formlist.add(data);
  8. for each  subRow in subform
  9. {
  10. data.put("Company_Name",subRow.get("Name_of_Supplier"));
  11. data.put("Location",subRow.get("Location"));
  12. data.put("First_Name",subRow.get("First_Name"));
  13. data.put("Email_1",subRow.get("Credit_Reference_Email"));
  14. data.put("Last_Name",subRow.get("Last_Name"));
  15. formlist.add({"Billing_Details":subRow.get("Credit_Reference")});
  16. //formlist.add(data);
  17. }
  18. //info formlist;
  19. //fetch Contract Mangagemnt Records associated to the opportunity
  20. contractRecords = zoho.crm.getRelatedRecords("Contracting","Deals",DealID);
  21. //info contractRecords;
  22. //This assumes one contract per opportunity - get the contract record id
  23. for each  contractRecord in contractRecords
  24. {
  25. contractId = contractRecord.get("id");
  26. //info contractId;
  27. }
  28. //Note, this will overwrite the credit references from the opportunity
  29. // Update contract subform with opportunity subform data
  30. subformParam = Map();
  31. subformParam.put("Billing_Details",formlist);
  32. subformResponse = zoho.crm.updateRecord("Contract_Management",toLong(contractId),subformParam);
  33. info subformResponse;

Thanks,
Jason

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





                                                                            Design. Discuss. Deliver.

                                                                            Create visually engaging stories with Zoho Show.

                                                                            Get Started Now