Generate a QR Code or Barcode in Zoho Creator with Deluge

Generate QR Codes and Barcodes in Zoho Creator

Print a QR code on a label, put a Code 128 barcode on a picking slip, let a warehouse scanner read a lot number straight off a Creator record. Generating the image takes one HTTP call and no library.

The service the original used no longer exists. barcodes4.me has no DNS record at all — the domain does not resolve. Every image generated by the original script is a broken image today, and because the URL was plain http:// it would have been blocked as mixed content on any HTTPS page regardless. This article uses QuickChart, which is free, HTTPS, and handles both QR codes and linear barcodes. There is a second change worth understanding: the original stored an <img src=...> HTML string in a text field rather than fetching the image. That means the picture only ever existed on someone else's server — which is exactly why every one of those records is now blank.

Before you start

  • A form with the value to encode, an image or file-upload field to hold the result, and optionally a text field for the encoded value.
  • No account and no API key. QuickChart’s free tier needs neither.

Deluge function

// ============================================
// GENERATE A QR CODE OR BARCODE IMAGE
// Stores a real image file on the record, not an <img> tag.
// ============================================

void Updates.generateBarcode(int recordId)
{
    rec = Collections[ID == recordId];

    value = ifnull(rec.Lote,"").toString();
    if(value == "")
    {
        info "Nothing to encode on record " + recordId;
        return;
    }

    encoded = zoho.encryption.urlEncode(value);

    // QR code
    qrUrl = "https://quickchart.io/qr?text=" + encoded + "&size=300";

    // Linear barcode instead? Swap the line above for:
    // qrUrl = "https://quickchart.io/barcode?type=code128&text=" + encoded
    //         + "&width=300&height=100";

    imageFile = invokeurl
    [
        url  : qrUrl
        type : GET
    ];

    // Store the actual file in an image or file-upload field
    rec.Barcode_Image = imageFile;
    rec.Barcode_Value = value;
}

Barcode types

Pass type= to the barcode endpoint. The common ones: code128 (the general default), code39, ean13 and upca for retail, itf for interleaved 2-of-5 on cartons, and qr. The original library listed Code 39, Code 128 a/b/c and interleaved 2-of-5 — all still available, just from a different provider.

Notes

  • Store the file, not a link. Fetching the image into a Creator field means the barcode still prints in five years when the generator service has been sold, rebranded or shut down. That is the entire lesson of this article.
  • URL-encode the value. zoho.encryption.urlEncode() handles spaces, slashes and accents. A lot number with a slash in it silently truncates without this.
  • Generate once, on create. The barcode for a record does not change, so there is no reason to regenerate it on every edit. Guard with if(rec.Barcode_Image == null).
  • Alternatives. api.qrserver.com/v1/create-qr-code/?size=300x300&data=VALUE is a good QR-only fallback. Avoid community-hosted demo endpoints for production — they carry no uptime guarantee, which is how you end up where barcodes4.me left everyone.

This script is part of the free Creator Scripts Deluge Library.

All 39 Deluge scripts, the full Zoho Creator course, and every downloadable asset are now free. Get free access →