Blog

Automation of Quote Creation in Zoho CRM using Deluge and WorkDrive + Sheet

In this example, we’ll show how Deluge can be used to fully automate the process of
generating a Quote from retrieving data from Zoho CRM to creating a product table in Zoho
Sheet and automatically saving the final file to Zoho WorkDrive.
Below is the complete function code that performs this process:
info QuoteID; // Table Quote = invokeurl [ url :"https://www.zohoapis.eu/crm/v8/Quotes/" + QuoteID type :GET connection:"crm_zoho_dev" ]; Quote = Quote.get("data").toMap(); Subject = Quote.get("Subject"); Account_Name = Quote.get("Account_Name"); if(Account_Name.isNull() == false) { Account_Name = Account_Name.get("name"); } Contact_Name = Quote.get("Contact_Name"); if(Contact_Name.isNull() == false) { Contact_Name = Contact_Name.get("name"); } Owner = Quote.get("Owner").get("name"); Delivery_address = Quote.get("Delivery_address"); Ready_by_date = Quote.get("Ready_by_date"); Sub_Total = Quote.get("Sub_Total"); Valid_Till = Quote.get("Valid_Till"); Grand_Total = Quote.get("Grand_Total"); Tax = Quote.get("Tax"); Adjustment = Quote.get("Adjustment"); currency_symbol = Quote.get("$currency_symbol"); Quoted_Items = Quote.get("Quoted_Items"); info Quoted_Items; row_data = list(); // Creating a list of lines // Table headings header = Map(); header.put("Product Name","Product Name"); header.put("Description","Description"); header.put("Quantity","Quantity"); header.put("Price","Price"); row_data.add(header); // Fill in the data resourceId = "m78m951ed261da6564fe898b2892823e9af51"; GrandTotal = 0; for each rec in Quoted_Items { Product_Name = rec.get("Product_Name").get("name"); Article = rec.get("Article"); Color = rec.get("Color"); Packaging = rec.get("Packaging"); Fabric_model = rec.get("Fabric_model"); Print_size = rec.get("Print_size"); Product_size = rec.get("Product_size"); Print_type = rec.get("Print_type"); Quantity = rec.get("Quantity"); List_Price = rec.get("List_Price"); Total = rec.get("Total"); Link = rec.get("Link"); Parent_Id = rec.get("id"); Preview = rec.get("Preview"); for each rec in Preview { fileId = rec.get("File_Id__s"); info "fileId: " + fileId; File_Name__s = rec.get("File_Name__s"); if(rec.get("File_Id__s") != null) { // Uploading a file by fileId fileDownloadUrl = "https://www.zohoapis.eu/crm/v8/files?id=" + fileId; // Make a GET request file = invokeurl [ url :fileDownloadUrl type :GET connection:"crm_zoho_dev" ]; info file; file.setParamName("file"); // header.put("x-filename",File_Name__s); header.put("x- parent_id","m78m95115e88cd68f4978895817486547edf4"); header.put("upload-id",fileId); header.put("x-streammode","1"); response = invokeurl [ url :"https://upload.zoho.eu/workdrive- api/v1/stream/upload" type :POST parameters:file headers:header connection:"workdrive" content-type:"application/octet-stream" ]; info response; // resource_id = response.get("data").get(0).get("attributes").get("resource_id "); info resource_id; Preview = "https://previewengine- accl.zoho.eu/image/WD/" + resource_id; } } // Preview = "=IMAGE(\"" + Preview + "\";1)"; info Preview; // row = Map(); row.put("Product Name",Product_Name); row.put("Preview",Preview); row.put("Q",Quantity); row.put("Item Price",List_Price); row.put("Total Price",Total); row.put("Link",Link); row.put("Article",Article); row.put("Color",Color); row.put("Fabric / model",Fabric_model); row.put("Packaging",Packaging); row.put("Product Size",Print_size); row.put("Print Type",Print_type); row.put("Print Size",Print_size); row.put("Project name",Account_Name); row.put("Account manager",Owner); row.put("Delivery info",Delivery_address); row.put("Ready by date",Ready_by_date); rowsData = List(); rowsData.add(row); queryData = Map(); response = zoho.sheet.createRecords(resourceId,"Sheet2",rowsData,queryDat a,"zoho_sheet"); } paramMap = Map(); paramMap.put('method','workbook.copy'); paramMap.put('resource_id',resourceId); paramMap.put('workbook_name',Subject); paramMap.put('parent_id','hmb7xd57420ae63934e46991c703d67eae9d e'); paramMap.put('copy_lock_settings','true'); response = invokeurl [ url :"https://sheet.zoho.eu/api/v2/copy" type :POST parameters:paramMap connection:"zoho_sheet" ]; info response; workbook_url = response.get("workbook_url"); info workbook_url; // formData = Map(); formData.put("attachmentUrl",workbook_url); formData.put("title",Subject); response = invokeurl [ url :"https://www.zohoapis.eu/crm/v7/Quotes/" + QuoteID + "/Attachments" type :POST parameters:formData connection:"crm_zoho_dev" ]; info response; // if(response.get("code").contains("DUPLICATE_DATA") == true) { result = response.get("message"); } else { result = "Files Generated"; } // paramMap = Map(); paramMap.put('method','range.content.clear'); paramMap.put('worksheet_name','sheet2'); paramMap.put('start_row',2); paramMap.put('start_column',1); paramMap.put('end_row',50); paramMap.put('end_column',17); response = invokeurl [ url :"https://sheet.zoho.eu/api/v2/" + resourceId type :POST parameters:paramMap connection:"zoho_sheet" ]; info response; return "Quote spreadsheet generated";
🧩 What this code does
1. Retrieves data for a specific Quote from Zoho CRM
All information — client, manager, delivery address, list of products, and totals — is extracted by ID.

2. Creates a table for Zoho Sheet
A header and rows with data for each product are generated: quantity, price, description, SKU, etc.

3. Uploads images to Zoho WorkDrive
Each image from the CRM is transferred to WorkDrive and returned as a preview link, inserted directly into the spreadsheet as the =IMAGE() formula.

4. Creates the final document in Zoho Sheet
The script adds rows to the sheet, then copies the workbook with a new name (for example, “Quote #123”).

5. Attaches the final file to the CRM record
A link to the generated document is saved in Zoho CRM as an attachment to the Quote.

6. Clears the template for next use
After generation is complete, the temporary data in the Zoho Sheet template is cleared.

Result
The manager clicks one button and the system automatically:
— generate a product table with images,​
— save the document in WorkDrive,​
— attach the file link to the CRM.
The entire process takes just a few seconds, instead of tens of minutes of manual preparation.