pop_id = 5971686000095722155; pop_details = zoho.crm.getRecordById("POP_Requests",pop_id); //info "pop_details ==>" + pop_details; Customer_Name = pop_details.get("Customer_Name"); //info "Customer_Name ==>" + Customer_Name; Payment_Date = pop_details.get("Payment_Date"); //info "Payment_Date ==>" + Payment_Date; Amount_Paid = pop_details.get("Amount_Paid"); //info "Amount_Paid ==>" + Amount_Paid; Unit = pop_details.get("Unit"); //info "Unit ==>" + Unit; EOI_owner = ifnull(pop_details.get("EOI"),""); //info "EOI_owner ==>" + EOI_owner; EOI = ifnull(EOI_owner.get("name"),""); //info "EOI ==>" + EOI; Payment_Mode = pop_details.get("Payment_Mode"); //info "Payment_Mode ==>" + Payment_Mode; Project_owner = pop_details.get("Project"); //info "Project_owner ==>" + Project_owner; Project_name = Project_owner.get("name"); //info "Project_name ==>" + Project_name; merge_doc_details = invokeurl [ url :"https://www.zohoapis.com/writer/api/v1/documents/kphns9739e715cf504f968324d0e7a0d362a7/fields" type :GET connection:"mail_merge" ]; //info "merge_doc_details ==>" + merge_doc_details; merge = merge_doc_details.get("merge"); //info "merge ==>" + merge; for each my_merge in merge { info "my_merge ==>" + my_merge; } attachment_id = "kphns9739e715cf504f968324d0e7a0d362a7"; emailData = Map(); fromDetails = Map(); fromDetails.put("email",zoho.loginuserid); emailData.put("from",fromDetails); toList = list(); toUser = Map(); toUser.put("email","drbunny819@gmail.com"); toList.add(toUser); emailData.put("to",toList); emailData.put("subject","Proof of Payment - " + Customer_Name + " - " + Project_name); emailData.put("org_email",false); // Attachments attachmentList = list(); attachment = Map(); attachment.put("id",attachment_id); attachmentList.add(attachment); emailData.put("attachments",attachmentList); // Email Template (Optional) template = Map(); template.put("id","5971686000095227019"); emailData.put("template",template); // Final Payload emailDataList = list(); emailDataList.add(emailData); emailRequest = Map(); emailRequest.put("data",emailDataList); inner_data = Map(); inner_data.put("id",pop_id); inner_data.put("Customer_Name",Customer_Name); inner_data.put("Payment_Date",Payment_Date); inner_data.put("Project",Project_name); inner_data.put("Amount_Paid",Amount_Paid); inner_data.put("Unit",Unit); inner_data.put("EOI",EOI); inner_data.put("Payment_Mode",Payment_Mode); data = Map(); data.put("data",inner_data); mergedata = Map(); mergedata.put("merge_data",data); mergedata.put("subject","Proof of Payment - " + Customer_Name + " - " + Project_name); //////////////////// File = zoho.writer.mergeAndDownload(attachment_id,"pdf",mergedata,"mail_merge"); //info "File ==> " + File; File.setParamName("file"); upload_response = invokeurl [ url :"https://www.zohoapis.com/crm/v6/files" type :POST files:File connection:"newzohocrm" ]; //info upload_response; ////////////////// ////////////////////////// ///////////////////////////////// upload_data = upload_response.get("data"); for each rec in upload_data { file_id = rec.get("details").get("id"); //info file_id; } // Email parameters from_email = "crm@leosuk.com"; manager_email_id = "muhammad.usman@leosops.com"; finallist = List(); frommp = Map(); frommp.put("email",from_email); frommp.put("user_name","LEOS Developments LLC"); mp = Map(); mp.put("from",frommp); tomaplist = List(); tomap = Map(); tomap.put("email",manager_email_id); tomap.put("user_name","Usman"); tomaplist.add(tomap); mp.put("to",tomaplist); // Email Template TemplateID = "5971686000095227019"; templatemap = Map(); templatemap.put("id",TemplateID); mp.put("template",templatemap); mp.put("org_email",true); // Attachments attachmentlist = List(); attachmentmap = Map(); attachmentmap.put("id",file_id); attachmentlist.add(attachmentmap); mp.put("attachments",attachmentlist); // Final payload finallist.add(mp); finalmap = Map(); finalmap.put("data",finallist); //info finalmap; // Send Email send_mail_resp = invokeurl [ url :"https://www.zohoapis.com/crm/v5/POP_Requests/" + pop_id + "/actions/send_mail" type :POST parameters:finalmap.toString() connection:"newzohocrm" ]; info "Sendmail: " + send_mail_resp;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter