Send Proposal to Customer as a attachment using Zoho CRM Inventory Template in Custom Function

Sending Proposal to Customer as a attachment using Zoho CRM Inventory Template

Introduction: This guide explains how to send a proposal (quote) to a customer in Zoho CRM using a pre-defined inventory template and automation through a Deluge script.

Overview: The following code sends a quotation to a customer by generating a PDF from an inventory template and attaching it to an email. The quote and deal details are fetched from Zoho CRM, and the email is automatically generated and sent. 

Deluge Script Code:
  1. // Inventory Template ID
  2. v_TemplateID = "6076403000000528121";
  3. // Quotation ID
  4. p_QuoteID = "60764030000005287854"
  5. //Deal Record ID
  6. record_id = "60764030000005287854"
  7. // get the quote details given a record ID
  8. r_QuoteDetails = zoho.crm.getRecordById("Quotes",p_QuoteID);
  9. v_Url = "https://zohoapis.com/crm/v2/settings/inventory_templates/" + v_TemplateID + "/actions/print_preview?record_id=" + p_QuoteID + "&print_type=pdf";
  10. f_FileRequest = invokeurl
  11. [
  12. url :v_Url
  13. type :GET
  14. connection:"arsh"
  15. ];
  16. info f_FileRequest;
  17. info "===============";
  18. f_FileRequest.setParamName("file");
  19. f_FileRequest.setFileName(r_QuoteDetails.get("Subject") + ".pdf");
  20. info f_FileRequest;
  21. // v_ContactName = contactData.get("Full_Name");
  22. EmailSubject = "Quote " + r_QuoteDetails.get("Subject");
  23. EmailMessage = "Dear " + v_ContactName + ",<br /><br />Attached is the quotation for your review.<br /><br />Best regards, <br /><br />Team StemRx";
  24. sendmail
  25. [
  26. from :zoho.loginuserid
  27. to :custEmail
  28. subject :EmailSubject
  29. message :EmailMessage
  30. Attachments :file:f_FileRequest
  31. ]

Conclusion:

This Deluge script automates the process of sending a proposal to customers from Zoho CRM by:

  • Fetching the quote and template details
  • Generating a PDF using an inventory template
  • Sending the PDF to the customer via email

Notes:

  • Ensure that you have the correct template ID (v_TemplateID).
  • Make sure that the contact's email address (custEmail) and deal ID (dealID) are correctly fetched or provided.
  • The connection name arsh should be configured under Connections in Zoho CRM to make API calls.