Levenshtein Distance in Zoho Deluge (Because Why Not?)

Levenshtein Distance in Zoho Deluge (Because Why Not?)

Ever wanted to run a Levenshtein Distance algorithm inside Zoho Deluge? No? Me neither, but I did it anyway.

I built a fully functional fuzzy matching system inside Zoho, brute-forcing a dynamic programming solution using Maps and recursive list generation.

  • Does it scale? Not really.
  • Does it work? Absolutely.
  • Did I need to do this? Not at all, but it was fun.

I don’t even use this anymore because I found a better way around fuzzy matching for my needs, but hey, if you ever need a low volume Levenshtein calculator inside Zoho, now you have one. 🤷‍♂️


How It Works

The function computes Levenshtein Distance, a metric for fuzzy string similarity, by calculating the number of insertions, deletions, and substitutions needed to convert one string into another.

This method is commonly used in spell-checking, DNA sequencing, and fuzzy search algorithms—so obviously, I decided to implement it inside Zoho, because why not?

🔹 The Challenge: Zoho doesn’t support 2D arrays natively.
🔹 The Solution: I brute-forced it using Map-of-Maps as a manual matrix.
🔹 Bonus: I even used recursion to generate number sequences (which is completely unnecessary but kinda cool).

Code & Example Usage

Main Function: standalone.levenshteinDistance

📌 Input: {"s": "kitten", "t": "sitting"}
📌 Output: "3"

Code:

string standalone.levenshteinDistance(Map args)
{
// Retrieve input strings.
s = args.get("s");
t = args.get("t");
m = s.length();
n = t.length();
// If one string is empty, return the length of the other.
if(m == 0)
{
return n.toString();
}
if(n == 0)
{
return m.toString();
}
//info "Length of s: " + m.toString() + ", Length of t: " + n.toString();
// ------------------------------
// Get index lists via the helper function.
// The helper function standalone.UtilitygetListOfLength returns a comma-separated string.
// For example, if (m+1) is 5, it returns "0,1,2,3,4".
// ------------------------------
indices_m_str = standalone.UtilitygetListOfLength({"myLength":m + 1});
indices_n_str = standalone.UtilitygetListOfLength({"myLength":n + 1});
//info "indices_m_str: " + indices_m_str;
//info "indices_n_str: " + indices_n_str;
// Convert these comma-separated strings into lists of long values.
indices_m = list();
numList_m = indices_m_str.toList(",");
for each  numStr in numList_m
{
if(numStr.trim() != "")
{
indices_m.add(numStr.trim().toLong());
}
}
indices_n = list();
numList_n = indices_n_str.toList(",");
for each  numStr in numList_n
{
if(numStr.trim() != "")
{
indices_n.add(numStr.trim().toLong());
}
}
//info "indices_m list: " + indices_m.toString();
//info "indices_n list: " + indices_n.toString();
// ------------------------------
// Initialize matrix as a map-of-maps.
// Each row is a map keyed by the column index.
// ------------------------------
matrix = Map();
for each  i in indices_m
{
rowMap = Map();
for each  j in indices_n
{
rowMap.put(j,0);
}
matrix.put(i,rowMap);
}
// Set up the first column: matrix[i][0] = i.
for each  i in indices_m
{
rowMap = matrix.get(i);
rowMap.put(0,i);
}
// Set up the first row: matrix[0][j] = j.
firstRow = matrix.get(0);
for each  j in indices_n
{
firstRow.put(j,j);
}
// ------------------------------
// Compute Levenshtein distances.
// ------------------------------
for each  i in indices_m
{
if(i == 0)
{
continue;
}
for each  j in indices_n
{
if(j == 0)
{
continue;
}
// Determine cost: 0 if characters are the same, otherwise 1.
if(s.subString(i - 1,i) == t.subString(j - 1,j))
{
cost = 0;
}
else
{
cost = 1;
}
deletion = matrix.get(i - 1).get(j) + 1;
insertion = matrix.get(i).get(j - 1) + 1;
substitution = matrix.get(i - 1).get(j - 1) + cost;
minValue = deletion;
if(insertion < minValue)
{
minValue = insertion;
}
if(substitution < minValue)
{
minValue = substitution;
}
rowMap = matrix.get(i);
rowMap.put(j,minValue);
}
}
result = matrix.get(m).get(n);
//info "Levenshtein distance: " + result.toString();
return result.toString();
}

Recursive Helper Function: standalone.UtilitygetListOfLength

📌 Input: {"myLength": 6}
📌 Output: "0,1,2,3,4,5"

Code:

string standalone.UtilitygetListOfLength(Map args)
{
myLength = args.get("myLength");
//info "Input myLength: " + myLength;
if(myLength == null || myLength <= 0)
{
//info "Base case reached (myLength <= 0). Returning empty string.";
return "";
}
else
{
// Recursively get the string for (myLength - 1)
prevStr = standalone.UtilitygetListOfLength({"myLength":myLength - 1});
//info "Previous string returned for myLength " + (myLength - 1).toString() + ": " + prevStr;
if(prevStr.equals(""))
{
result = "0";
}
else
{
result = prevStr + "," + (myLength - 1).toString();
}
//info "Returning result for myLength " + myLength.toString() + ": " + result;
return result;
}
}

This helper function is completely unnecessary, but I made it anyway. Instead of just looping, it recursively builds a CSV string of numbers—which is both inefficient and hilarious. 😆

Why Did I Do This?

Because it wasn't supposed to work—but it does.

  • Zoho doesn’t support Levenshtein distance? I built it anyway.
  • Zoho doesn’t have fuzzy matching? Now it does.
  • Zoho doesn’t support 2D arrays? I brute-forced a matrix using Maps.
  • Does this scale for massive data? Nope, but it’s perfect for low-volume cases.

Thoughts? Ideas? Have you ever done something in Zoho just because you wanted to see if it was possible? Let me know. 😆


TL;DR:

📌 I brute-forced Levenshtein Distance into Zoho
📌 Zoho wasn’t built for this, but I made it work anyway
📌 Does it scale? No. Does it work? Yes.
📌 Do I use it? Nope. Was it fun? Absolutely.

Let me know what you think! 🚀



      • Sticky Posts

      • Kaizen #197: Frequently Asked Questions on GraphQL APIs

        🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Kaizen #198: Using Client Script for Custom Validation in Blueprint

        Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

        Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
      • Kaizen #193: Creating different fields in Zoho CRM through API

        🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
      • Client Script | Update - Introducing Commands in Client Script!

        Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands

        • Recent Topics

        • Billing Management: #4 Negate Risk Free with Advances

          In the last post, we explored how unbilled charges accumulate before being invoiced. But what happens when businesses need money before service begins? Picture this: A construction company takes on a $500,000 commercial building project expected to last
        • Is there an equivalent to the radius search in RECRUIT available in the CRM

          We have a need to find all Leads and/or Contacts within a given radius of a given location (most likely postcode) but also possibly an address. I was wondering whether anyone has found a way to achieve this in the CRM much as the radius search in RECRUIT
        • Zoho CRM Inventory Management

          What’s the difference between Zoho CRM’s inventory management features and Zoho Inventory? When is it better to use each one?
        • Cannot Enable Picklist Field Dependency in Products or Custom Modules – Real Estate Setup

          Hello Zoho Support, I am configuring Zoho CRM for real estate property management and need picklist field dependency: What I’ve tried: I started by customizing the Products module (Setup > Modules & Fields) to create “Property Type” (Housing, Land, Commercial)
        • How to add application logo

          I'm creating an application which i do not want it to show my organization logo so i have changed the setting but i cannot find where to upload/select the logo i wish to use for my application. I have seen something online about using Deluge and writing
        • Get Workflow Metadata via API

          Is there a way to get metadata on workflows and/or custom functions via API? I would like to automatically pull this information. I couldn't find it in the documentations, but I'm curious if there is an undocumented endpoint that could do this. Moderation
        • Zoho Projects - Q2 Updates | 2025

          Hello Users, With this year's second quarter behind us, Zoho Projects is marching towards expanding its usability with a user-centered, more collaborative, customizable, and automated attribute. But before we chart out plans for what’s next, it’s worth
        • FSM setup

          So we have been tinkering with FSM to see if it is going to be for us. Now is the time to bite the bullet and link it to our zoho books and zoho crm. The help guides are good but it would really help if they were a bit more in depth on the intergrations.
        • Upcoming Updates to the Employees Module in Zoho Payroll (US)

          We've made a couple of updates to the Employees module in Zoho Payroll (latest version of the US edition). These changes will go live today. While creating an employee Currently, the Compensation Details section is part of the Basic Details step, where
        • Possible to Turn Off Automatic Notifications for Approvals?

          Hello, This is another question regarding the approval process. First a bit of background: Each of our accounts is assigned a rank based on potential sales. In Zoho, the account rank field is a drop-down with the 5 rank levels and is located on the account
        • ZOHO Creator subform link

          Dear Community Support, I am looking for some guidance on how to add a clickable link within a Zoho Creator subform. The goal is for this link to redirect users to another Creator form where they can edit the data related to the specific row they clicked
        • Allow Resource to Accept or Reject an Appointment

          I have heard that this can be done, is there any documentation on how?
        • Create new Account with contact

          Hi I can create a new Account and, as part of that process, add a primary contact (First name, last name) and Email. But THIS contact does NOT appear in Contacts. How can I make sure the Contact added when creating an Account is also listed as a Contact?
        • Custom Fonts in Zoho CRM Template Builder

          Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
        • Python - code studio

          Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
        • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

          Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
        • How To Insert Data into Zoho CRM Organization

          Hi Team I have this organization - https://crm.zoho.com/crm/org83259xxxx/tab/Leads I want to insert data into this Leads module, what is the correct endpoint for doing so ? Also I have using ZohoCRM.modules.ALL scope and generated necessary tokens.
        • Where can I get Equation Editor por Zoho Writer?

          I need to use Math Formulas in my document. Thank you.
        • How can I get base64 string from filecontent in widget

          Hi, I have a react js widget which has the signature pad. Now, I am saving the signature in signature field in zoho creator form. If I open the edit report record in widget then I want to display the Signature back in signature field. I am using readFile
        • Creator roadmap for the rest of 2022

          Hi everyone, Hope you're all good! Thanks for continuing to make this community engaging and informative. Today we'd like to share with you our plans for the near future of Creator. We always strive to strike a good balance of features and enhancements
        • Filtering repport for portal users

          Salut, I have a weird problem that I just cannot figure out : When I enter information as administrator on behalf of a "supplier" portal user (in his "inventory" in a shared inventory system), I can see it, "customer" portal users can see it, but the
        • Zoho Inventory. Preventing Negative Stock in Sales Orders – Best Practices?

          Dear Zoho Inventory Community, We’re a small business using Zoho Inventory with a team of sales managers. Unfortunately, some employees occasionally overlook stock levels during order processing, leading to negative inventory issues. Is there a way to
        • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

          Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
        • Zoho One - Syncing Merchants and Vendors Between Zoho Expense and Zoho Books

          Hi, I'm exploring the features of Zoho One under the trial subscription and have encountered an issue with syncing Merchant information between Zoho Expense and Zoho Books. While utilizing Zoho Expense to capture receipts, I noticed that when I submit
        • Is Zoho Sheet available for Linux ?

          Is Zoho Sheet available for Linux ?
        • Offline support for mobile app

          Accessing your files and folders from your mobile devices is now quicker and simpler, thanks to the power of offline support. Whether on an Android or iOS device, you can use the Offline function to save files and folders, so you can review them even
        • Zoho Sheet for Desktop

          Does Zoho plans to develop a Desktop version of Sheet that installs on the computer like was done with Writer?
        • Create static subforms in Zoho CRM: streamline data entry with pre-defined values

          Last modified on (9 July, 2025): This feature was available in early access and is currently being rolled out to customers in phases. Currently available for users in the the AU, CA, and SA DCs. It will be enabled for the remaining DCs in the next couple
        • BUTTONS SHOWN AS AN ICON ON A REPORT

          Hi Is there any way to create an action button but show it as an icon on a report please? As per the attached example? So if the user clicks the icon, it triggers an action?
        • Dropshipping Address - Does Not Show on Invoice Correctly

          When a dropshipping address is used for a customer, the correct ship-to address does not seem to show on the Invoice. It shows correctly on the Sales Order, Shipment Order, and Package, just not the Invoice. This is a problem, because the company being
        • RFQ MODEL

          A Request for quotation model is used for Purchase Inquiries to multiple vendors. The Item is Created and then selected to send it to various vendors , once the Prices are received , a comparative chart is made for the user. this will help Zoho books
        • Will zoho thrive be integrated with Zoho Books?

          title
        • Product Updates in Zoho Workplace applications | August 2025

          Hello Workplace Community, Let’s take a look at the new features and enhancements that went live across all Workplace applications this August. Zoho Mail Delegate Email Alias Now you can let other users send emails on your behalf—not just from your primary
        • Notebook audio recordings disappearing

          I have recently been experiencing issues where some of my attached audio recordings are disappearing. I am referring specifically to ones made within a Note card in Notebook on mobile, made by pressing the "+" button and choosing "Record audio" (or similar),
        • Unable to send message; Reason:554 5.1.8 Email Outgoing Blocked

          Hi, I sent few emails and got this: Unable to send message; Reason:554 5.1.8 Email Outgoing Blocked And now I have few days since I cant send any email. Is there something wrong I did? Also can someone fix this please
        • Want to use Zoho Books in Switzerland. CHF support planned?

          Hi, We're a Swiss company using other Zoho suite software and I discovered Zoho Books and other accounting SaaS when looking for an accounting tool. Do you intend to cover Switzerland and CHF based accounting anytime soon? Roy
        • Zoho sheet desktop version

          Hi Zoho team Where can I access desktop version of zoho sheets? It is important as web version is slow and requires one to be online all the time to do even basic work. If it is available, please guide me to the same.
        • Weekly Tips : Teamwork made easy with Multiple Assignees

          Let's say you are working on a big project where different parts of a single task need attention from several people at the same time—like reviewing a proposal that requires input from sales, legal, and finance teams. Instead of sending separate reminders
        • Best way to share/download presentation files in Zoho without losing formatting?

          Hello Zoho Community, I often work with PPT/PDF files in Zoho Docs and share them with colleagues. While PDFs usually give a direct download option, I’ve noticed that PPT/PPTX files sometimes only open in the viewer without a clear download link. Is there
        • Celebrating Connections with Zoho Desk

          September 27 is a special day marking two great occasions: World Tourism Day and Google’s birthday. What do these two events have in common (besides the date)? It's something that Zoho Desk celebrates, too: making connections. The connect through tourism
        • Next Page