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

        • Migrate Your Notes from OneNote to Zoho Notebook Today

          Greetings Notebook Users, We’re excited to introduce a powerful new feature that lets you migrate your notes from Microsoft OneNote to Zoho Notebook—making your transition faster and more seamless than ever. ✨ What’s New One-click migration: Easily import
        • Deluge sendmail in Zoho Desk schedule can't send email from a verified email address

          I am trying to add a scheduled action with ZDesk using a Deluge function that sends a weekly email to specific ticket client contacts I've already verified the email address for use in ZDesk, but sendmail won't allow it in its "from:" clause. I've attached
        • Zoho Campaigns - Why do contacts have owners?

          When searching for contacts in Zoho Campaigns I am sometimes caught out when I don't select the filter option "Inactive users". So it appears that I have some contacts missing, until I realise that I need to select that option. Campaigns Support have
        • One Contact with Multiple Accounts with Portal enabled

          I have a contact that manages different accounts, so he needs to see the invoices of all the companies he manage in Portal but I found it not possible.. any idea? I tried to set different customers with the same email contact with the portal enabled and
        • End Date in Zoho Bookings

          When I give my appointments a 30 minutes time I would expect the software not to even show the End Time.  But it actually makes the user pick an End Time.  Did I just miss a setting?  
        • Zoho Commerce

          Hi, I have zoho one and use Zoho Books. I am very interested in Zoho Commerce , especially with how all is integrated but have a question. I do not want my store to show prices for customers that are not log in. Is there a way to hide the prices if not
        • email forwarding not working

          Your email forwarding service does not work. I received the confirmation email and completed the confirmation, after that nothing and nothing since no matter what I have tried. Shame as everything else was smooth. I spose it's harder to run one of these web based internet mail services than you guys thought!!! can you fix the email forwarding asap PLEASE!
        • Google Ads Conversions Not Being Tracked in Zoho CRM

          We have 3 different conversions created in our Google Ads Account. Only one of the 3 conversion types is tracking in Zoho CRM. Our forms are Elementor Forms that are mapped into Zoho CRM. It apprears to me that all leads are showing up in Zoho CRM, but
        • Zoho Desk KB article embedded on another site.

          We embed KB articles from Zoho Desk on another site (our application). When opening the article in a new tab, there is no issue, but if we choose lightbox, we are getting an error "To protect your security, help.ourdomain.com will not allow Firefox to
        • Enable Locations for Expense

          Hi, please enable Locations (ex Branches) for Zoho Expense so that there is consistency between this app and Zoho Books. Thanks in advance.
        • Currency abbreviations

          Hello, Im stuck, and need help. I need the currency fields for example, opportunity value, or total revenue, to be abbreviated, lets say for 1,000 - 1K, 1,000,000 - 1M, and so on, how should I do this?
        • Losing description after merging tickets

          Hello, We merge tickets when they are about the same topic from the same client. It happens sometimes. We recently noticed that after the merger only the description from the master ticket is left in a thread. And the slave-ticket description is erased.
        • in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books

          in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books . how I get the file From zoho creator and upload to Zoho Books . using Api response = invokeUrl [ url: "https://www.zohoapis.com/creator/v2.1/data/hh/l130/report/All_Customer_Payments/"+input.ID
        • Generate a link for Zoho Sign we can copy and use in a separate email

          Please consider adding functionality that would all a user to copy a reminder link so that we can include it in a personalized email instead of sending a Zoho reminder. Or, allow us to customize the reminder email. Use Case: We have clients we need to
        • Syntax for URLs in HTML Snippets

          What are some best practices for inserting a URL in an HTML snippet? I've looked at Zoho Help articles on navigation-based and functional-based URLs, but I'm still unclear on how to incorporate them in an HTML snippet. For example, 1. How do I link to
        • Rate Limiting in Zoho Flow (OpenAI API)

          Hi Everyone, We are facing some issues when using Zoho Flow as we have a deluge script running which is making external calls to OpenAI endpoint. Sometimes the response takes more than 30 seconds meaning the script will timeout. We want to implement a
        • Placing a condition before converting the LEAD

          Hi,  I need some assistance with Lead conversion. I need to place certain conditions before allowing the user to convert the lead.  For example: up until the certain status's doesn't equal "green" don't allow to convert lead.  I tried creating this using
        • it is possible to open a widget via deluge script function

          I have one function that is workflow action I call my fucntion I need to call the internal widget it is possible to open or it have to please tell me the solution
        • Creator - Portal Custom Domain

          I will pay $100 in crypto to anyone who can actually get my Creator Custom Domain to function (actually tell me how you got yours to).  Domain verifies, Nothing. I've been fighting it a week, multiple chats to customer service. Clearly I'm doing something wrong.  Some datapoints Domain name itself unimportant, can be a string of numbers.  I need to know what registrars are working for you because GoDaddy does NOT.  Do I need hosting? I've tried both ways and nothing works.  I pushed through Cloudflare
        • Transitioning to API Credits in Zoho Desk

          At Zoho Desk, we’re always looking for ways to help keep your business operations running smoothly. This includes empowering teams that rely on APIs for essential integrations, functions and extensions. We’ve reimagined how API usage is measured to give
        • steps and options to change Domain DNS/Nameservers settings

          Please share the options or steps to change  Domain DNS/Nameservers settings 
        • Unable to explore desk.zoho.com

          Greetings, I have an account with zoho which already has a survey subscription. I would like to explore desk.zoho.com, but when I visit it while logged in (https://desk.zoho.com/agent?action=CreatePortal) I just get a blank page. I have tried different
        • Employees in Leave Policy exceptions

          In the Leave Policies we should be able to add specific employees to the exception list So it will be like All Employees except A,B,C in the exception list, currently we can only add departments etc
        • Searching customer field

          Hello, When entering a receipt, we select customer information. The customer information is synced with Zoho CRM. However, we can't find the customer information because it searches for words that begin with the entered value. It needs to search for words
        • How I set default email addresses for Sales Orders and Invoices

          I have customers that have different departments that handle Sales Orders and Invoices. How can i set a default email for Sales Orders that's different than the default email for Invoices? Is there a way I can automate this using the Contact Persons Departments
        • Modular Permission Levels

          We need more modular Permissions per module in Books we have 2 use cases that are creating problems We need per module export permission we have a use case where users should be able to view the sales orders but not export it, but they can export other
        • Kaizen #157: Flyouts in Client Script

          Hello everyone! Welcome back to another exciting edition of our Kaizen series, where we explore fresh insights and innovative ideas to help you discover more and expand your knowledge!In this post, we'll walk through how to display Flyouts in Client Script
        • How get stock name from other column ?

          How get stock name from other column ? e.g. =STOCK(C12;"price") where C12 is the code of the stock
        • Adding a developer for editing the client application with a single user license

          Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
        • Download an email template in html code

          Hello everyone, I have created an email template and I want to download it as html. How can i do that? I know you can do it via the campaigns-first create a campaign add the template and download it as html from there. But what if i don't want to create
        • Attachment is not included in e-mails sent through Wordpress

          I have a Wordpress site with Zeptomail Wordpress plugin installed and configured. E-mails are sent ok through Zeptomail but without the included attachment (.pdf file) Zeptomail is used to send tickets to customers through Zeptomail. E-Mails are generated
        • Upcoming Changes to the Timesheet Module

          The Timesheet module will undergo a significant change in the upcoming weeks. To start with, we will be renaming Timesheet module to Time Logs. This update will go live early next week. Significance of this change This change will facilitate our next
        • Best way to schedule bill payments to vendors

          I've integrated Forte so that I can convert POs to bills and make payments to my vendors all through Books. Is there a way to schedule the bill payments as some of my vendors are net 30, net 60 and even net 90 days. If I can't get this to work, I'll have
        • Cant update image field after uploading image to ZFS

          Hello i recently made an application in zoho creator for customer service where customers could upload their complaints every field has been mapped from creator into crm and works fine except for the image upload field i have tried every method to make
        • 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
        • Next Page