Deluge | How to Find Duplicate Values in a List Using Deluge Script

Deluge | Program to print or Identify the duplicates from a list of integers
A step-by-step guide to identifying and printing duplicate numbers from a list in Zoho's Deluge scripting language — with a clean, reusable code example.

What is Deluge?

Deluge (Data Enriched Language for the Universal Grid Environment) is Zoho's proprietary scripting language used to write custom functions, automation workflows, and business logic across Zoho applications — including Zoho CRM, Zoho Creator, Zoho Books, and more.

It is a straightforward, human-readable language that supports lists, maps, loops, and conditionals, making it easy to implement data-processing logic directly inside your Zoho environment without relying on external code.

Problem statement

Given a list of numbers, write a Deluge script that identifies and prints all values that appear more than once.

→ Input

[5, 3, 8, 5, 2, 8, 1]

✓ Expected Output

Duplicate values: [5, 8]

Why does this matter? Detecting duplicates is a common data quality task — whether you are cleaning up a CRM list, validating imported records, or auditing survey responses inside Zoho Creator.

How the script works

The approach uses a frequency map (Deluge's built-in map type) to count how many times each number appears, then collects any number with a count greater than one into a separate list.

  1. Define the input list — a fixed list of integers.
  2. Initialize a map to track how many times each value has been seen.
  3. Loop through the list — for each number, either increment its count in the map or add it with an initial count of 1.
  4. Loop through the map keys — any key with a count greater than 1 is a duplicate; add it to the duplicate list.
  5. Print the duplicate list using the info statement.

Complete code

deluge-script
// Step 1: Input list
list_v = [5, 3, 8, 5, 2, 8, 1];

// Step 2: Initialize an empty map and list for duplicates
appear_occurence_map = map();
duplicate_list = list();

// Step 3: Count occurrences of each number
for each number in list_v
{
    if(appear_occurence_map.containsKey(number))
    {
        appear_occurence_map.put(number, appear_occurence_map.get(number) + 1);
    }
    else
    {
        appear_occurence_map.put(number, 1);
    }
}

// Step 4: Identify duplicates
for each number in appear_occurence_map.keys()
{
    if(appear_occurence_map.get(number) > 1)
    {
        duplicate_list.add(number);
    }
}

// Step 5: Print the duplicates
info "Duplicate values: " + duplicate_list;

Output

When you run this script inside a Zoho Deluge environment (for example, in Zoho Creator's workflow or a custom function), the log output will show:

Duplicate values: [5, 8]

Both 5 and 8 appear twice in the original list, so they are correctly identified as duplicates.

Key Deluge functions used

Function Description
map()Creates an empty key-value map, similar to a dictionary in Python or an object in JavaScript.
containsKey(key)Returns true if the specified key already exists in the map.
put(key, value)Inserts or updates an entry in the map. Overwrites the value if the key already exists.
get(key)Retrieves the value associated with a given key from the map.
keys()Returns all keys in the map as a list, allowing iteration over every unique element.
list()Creates an empty list to store results.
add(value)Appends a value to the end of a list.
infoPrints a value to the Deluge log output — equivalent to print() in Python.

Conclusion

This script demonstrates one of the most practical patterns in Deluge — combining a map for frequency counting with a list for collecting results. The same pattern can be extended to detect duplicate strings, phone numbers, email addresses, or any other value type inside a Zoho workflow.

You can drop this snippet directly into a Zoho Creator custom function or a Zoho CRM workflow function and adapt the input list to pull from a real data source, such as a form field or a CRM module query.

Tip: To make this reusable, wrap the logic inside a Deluge function that accepts the list as a parameter and returns the duplicate list — no hardcoded values needed.



Post a Comment