Zoho CRM and Zoho Writer Merge and Send Function - Not Merging

Zoho CRM and Zoho Writer Merge and Send Function - Not Merging

Overall Problem
I needed a solution to automatically calculate and send employee payslip information stored on Zoho CRM, to each of our employees at the end of each month based on their salary, allowances and sales commissions (sales commissions - which may change each pay period based on deals completed)

Solution
I create a module on Zoho CRM called "Payslip Records", which contains records for each employee with their personal information, total sales commissions, allowances, net salary etc.

I then created a payslip template in Zoho Writer, and used the merge fields from the CRM "Payslips Module" to populate the fields on the payslip in Zoho Writer. If I run this manually from Zoho CRM, it works - the fields are merged and I can send the payslip to the employees via email.

Automating Challenge - Merge and Send Function in Zoho CRM not Merging Fields
So that the process could be automated with a workflow, I created a function which seems to be working - teh console log returns successful. However, when the function runs and the email is sent off I receive blank payslip templates in my inbox. Here's a look at my code below, can anyone explain why this might be happening that's wrong?

  1. payslipRecords = zoho.crm.getRecordById("Payslip_Records",payslipId,"crmwriter");
  2. fields = zoho.writer.getMergeFields("cpqhxd8f21b4c97794e3089ed074e21b45a51","crmwriter");
  3. info "fields : " + fields;
  4. info "payslipRecords : " + payslipRecords;
  5. data = Map();
  6. //data.put("First_Name", payslipRecords.get("Account_Name").get("name"));
  7. //data.put("Email", payslipRecords.get("Account_Name").get("id"));
  8. payslips = list();
  9. payslipfield = Map();
  10. payslipfield.put("Payslip_Records. Employee Name",ifnull(payslipRecords.get("Name"),""));
  11. payslipfield.put("Payslip Records. Department",ifnull(payslipRecords.get("Department"),""));
  12. payslipfield.put("Payslip Records. Pay Period",ifnull(payslipRecords.get("Pay_Period"),""));
  13. payslipfield.put("Payslip Records. Date of Payment",ifnull(payslipRecords.get("Date_of_Payment"),""));
  14. payslipfield.put("Payslip Records. Salary",ifnull(payslipRecords.get("Salary"),""));
  15. payslipfield.put("Payslip Records. Upfront Commissions",ifnull(payslipRecords.get("Upfront_Commissions"),""));
  16. payslipfield.put("Payslip Records. Recurring Commissions",ifnull(payslipRecords.get("Recurring_Commissions"),""));
  17. payslipfield.put("Payslip Records. Internet",ifnull(payslipRecords.get("Internet"),""));
  18. payslipfield.put("Payslip Records. Net Pay",ifnull(payslipRecords.get("Net_Pay"),""));
  19. payslips.add(payslipfield);
  20. data.put("Payslip_Records",payslips);
  21. mergedata = Map();
  22. mergedata.put("merge_data",{"data":data});
  23. mergedata.put("subject","Payslip Due");
  24. //optionalDF
  25. mergedata.put("message","Please find your payslip attached.");
  26. info "mergedata : " + mergedata;
  27. update = zoho.writer.mergeAndSend("cpqhxd8f21b4c97794e3089ed074e21b45a51","pdf",payslipRecords.get("Email"),mergedata,"crmwriter");
  28. info "update : " + update;

Console Information
  1. Info
    • fields : {"rl_fields":[],"fields":["Employee_Name"]}
    • payslipRecords : {"Salary":1000,"Owner":{"name":"John Doe","id":"4035844000008772172","email":"john@email.com"},"Email":"john@email.com","$currency_symbol":"Bds$","Net_Pay":1260.45,"$review_process":{"approve":false,"reject":false,"resubmit":false},"Name":"John Doe","Last_Activity_Time":null,"Record_Image":null,"Modified_By":{"name":"John Doe","id":"4035844000008772172","email":"john@email.com"},"Department":"Operations","$review":null,"$state":"save","Unsubscribed_Mode":null,"$process_flow":false,"Exchange_Rate":1,"Currency":"BBD","id":"4035844000024583003","$approved":true,"Recurring_Commissions":10.45,"$approval":{"delegate":false,"approve":false,"reject":false,"resubmit":false},"Modified_Time":"2021-02-23T10:20:21-04:00","Created_Time":"2021-02-23T10:20:21-04:00","Unsubscribed_Time":null,"$editable":true,"Date_of_Payment":"2021-02-28","$orchestration":false,"$in_merge":false,"Tag":[],"Internet":50,"Upfront_Commissions":200,"$approval_state":"approved","Pay_Period":"2021-02-15"}
    • mergedata : {"merge_data":{"data":{"Payslip_Records":[{"Payslip_Records. Employee Name":"John Doe","Payslip Records. Department":"Operations","Payslip Records. Pay Period":"2021-02-15","Payslip Records. Date of Payment":"2021-02-28","Payslip Records. Salary":1000,"Payslip Records. Upfront Commissions":200,"Payslip Records. Recurring Commissions":10.45,"Payslip Records. Internet":50,"Payslip Records. Net Pay":1260.45}]}},"subject":"Payslip Due","message":"Please find your payslip attached."}
    • update : {"merge_report_data_url":"https://docs.zoho.com/writer/api/v1/merge/job/aa5fea7ce716f6854f78ce450bf8333c67f0dd47c7f5a6b3f6fe5644fe18afcc/data","merge_report_url":"https://docs.zoho.com/writer/v1/mailmerge/job/aa5fea7ce716f6854f78ce450bf8333c67f0dd47c7f5a6b3f6fe5644fe18afcc","records":[{"download_link":"https://docs.zoho.com/writer/api/v1/merge/job/aa5fea7ce716f6854f78ce450bf8333c67f0dd47c7f5a6b3f6fe5644fe18afcc/record/aa5fea7ce716f6854f78ce450bf8333c9587b8912fcf060c77d27971ad2eecd9/attachment/1/download","SEQUENCE":1,"Payslip_Records":[{"Payslip Records. Net Pay":1260.45,"Payslip Records. Recurring Commissions":10.45,"Payslip Records. Department":"Operations","Payslip_Records. Employee Name":"John Doe","Payslip Records. Internet":50,"Payslip Records. Pay Period":"2021-02-15","Payslip Records. Date of Payment":"2021-02-28","Payslip Records. Upfront Commissions":200,"Payslip Records. Salary":1000}],"id":"758541b4-e20f-4275-a434-fe32553c3b65","status":"inprogress"}]}
    Function executed successfully

Please help if you can, thanks! I've attached images of the merge template with the field ID's in Zoho Writer for reference.






                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • [Important announcement] Impact of Google's new email guidelines for Zoho Writer automation users

                                          Hi users, Google has recently announced new guidelines for sending emails to Gmail and other Google-hosted domains. These guidelines will be effective starting Feb. 1, 2024, and can impact the delivery of emails sent from Zoho Writer. Your organization
                                        • Transitioning from MS Word to Writer: A complete walkthrough

                                          Hello everyone! We understand moving to a new word processing tool can be difficult, especially if it means switching from a legacy software like MS Word. That's why we've organized an exclusive webinar where we talk you through ways to make your switch from MS Word to Writer as easy as possible. In this webinar, you'll learn: - Why Writer is a simple yet powerful alternative to MS Word. - How to locate your favorite MS Word features and functions in Writer.  - How to migrate your Word documents
                                        • Writer Designer's Update 2018: What's Changed with Page Settings

                                          Hey there, Writers! =] As a part of the Writer Designer's Update 2018, here's everything new and improved with Tables in Writer: 1. Customizable horizontal lines  While horizontal lines act as separators for different sections in a document, they also make your document more visually appealing and easier to read. Keeping that in mind, we've now added some handy customization options for horizontal lines in the form of line weight, color, pattern, and alignment. 2. Beautiful page borders Give your
                                        • Zoho Clipboard App has been discontinued

                                          Hello there! Thanks to everyone who wrote to us. We could see you had trouble installing, and using both Zoho Writer and Zoho Clipboard Apps at the same time via Chrome Web Store. To avoid this conflict, we have decided to, as you've already guessed, discontinue the App, and bundle it with the Zoho Writer App itself. Chrome users will only need the Zoho Writer App now to enable Copy and Paste on right click. Here's the how to remove the Clipboard App: 1. Go to your Chrome Apps page by clicking on
                                        • First Look: The New and Improved Zoho Writer

                                          Preview the all-new Zoho Writer to see our cleaner, more stylish, and more intuitive interface. Click the Try New Version link on top of your Writer window and switch to a better experience.  Here's all that's new: Revamped UI With a brand new look, comes a whole new approach – introducing modes, a simpler way to write. The Compose mode gives you a space to write without distractions. Switch to the Review mode when it's time to add other people to the equation, and get feedback from your peers. When


                                        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