invoicesRecords = zoho.crm.getRecordById("Invoices",invoiceId);
data = Map();
data.put("First_Name",invoicesRecords.get("Account_Name").get("name"));
data.put("Email",invoicesRecords.get("Account_Name").get("id"));
invoicesList = list();
invoicesfield = Map();
invoicesfield.put("Invoices.Invoice_Number",invoicesRecords.get("Invoice_Number"));
invoicesfield.put("Invoices.Created_By",invoicesRecords.get("Created_By").get("name"));
invoicesfield.put("Invoices.Due_Date",invoicesRecords.get("Due_Date"));
invoicesfield.put("Invoices.Owner",invoicesRecords.get("Owner").get("name"));
invoicesList.add(invoicesfield);
data.put("Invoices",invoicesList); //Invoices - This key value is got from the 'id' value in the RL info
mergedata = Map();
mergedata.put("merge_data",{"data":data});
mergedata.put("subject","Invoice Data");
//optional
mergedata.put("message","Please find your invoice attached.");
info mergedata;
zoho.writer.mergeAndSend("eb4kob4cf65bb6d074af7a7de21e561119eb9","pdf",invoicesRecords.get("email"),mergedata,"writer_name");