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.
- Deal = zoho.crm.getRecordById("Deals",DealID);
- //info Deal;
- //Deal subform data
- subform = Deal.get("Credit_References");
- data = Map();
- formlist = List();
- //formlist.add(data);
- for each subRow in subform
- {
- data.put("Company_Name",subRow.get("Name_of_Supplier"));
- data.put("Location",subRow.get("Location"));
- data.put("First_Name",subRow.get("First_Name"));
- data.put("Email_1",subRow.get("Credit_Reference_Email"));
- data.put("Last_Name",subRow.get("Last_Name"));
- formlist.add({"Billing_Details":subRow.get("Credit_Reference")});
- //formlist.add(data);
- }
- //info formlist;
- //fetch Contract Mangagemnt Records associated to the opportunity
- contractRecords = zoho.crm.getRelatedRecords("Contracting","Deals",DealID);
- //info contractRecords;
- //This assumes one contract per opportunity - get the contract record id
- for each contractRecord in contractRecords
- {
- contractId = contractRecord.get("id");
- //info contractId;
- }
- //Note, this will overwrite the credit references from the opportunity
- // Update contract subform with opportunity subform data
- subformParam = Map();
- subformParam.put("Billing_Details",formlist);
- subformResponse = zoho.crm.updateRecord("Contract_Management",toLong(contractId),subformParam);
- info subformResponse;
Thanks,
Jason