In Zoho CRM, using Deluge, I am trying to fetch data from one subform ("Eval_Appt") from a custom module ("Client_Appointments") and copy this data to another subform ("Charges") in a custom module ("Billing_Invoices"). Below is the code that I have written. It successfully fetches the data that I need to be copied, but I am stuck on getting it to add a new row with associated data for each row from the "Eval_Appt" subform to the "Charges" subform. What should I do next?
rec = zoho.crm.getRecordById("Client_Appointments",recID);
bill = zoho.crm.getRelatedRecords("Billing_Invoices","Client_Appointments",recID);
bill_sub = bill.get("Charges");
for each field in bill_sub
{
bill_cpt = field.get("CPT_Code");
bill_unit = field.get("Units");
old_data = {"CPT_Code":"","Units":""};
info old_data;
}
eval = rec.get("Eval_Appt");
if(eval != null && eval.size() > 0)
{
}
for each index in eval
{
if(index.get("CPT_Code") != null && index.get("CPT_Code") != "")
{
eval_cpt = index.get("CPT_Code");
info eval_cpt;
}
if(index.get("Units") != null && index.get("Units") != "")
{
eval_unit = index.get("Units");
info eval_unit;
}
new_data = {"CPT_Code":eval_cpt,"Units":eval_unit};
info new_data;
}
subformsize = bill.get("Charges").size();
lastrow = subformsize + 1;
parammap = Map();
parammap.put("Billing_Invoices",lastrow);
addrow = zoho.crm.updateRelatedRecord(old_data,lastrow,eval,recID,new_data);
info parammap;
info addrow;