Kaizen 223 - File Manager in CRM Widget Using ZRC Methods

Kaizen 223 - File Manager in CRM Widget Using ZRC Methods

Hello, CRM Wizards!



Here is what we are improving this week with Kaizen. 

we will explore the new ZRC (Zoho Request Client) introduced in Widget SDK v1.5, and learn how to use it to build a Related List Widget that integrates with Zoho WorkDrive. It helps users to preview and upload files directly from the record’s detail page.

Why ZRC?

ZRC is a unified client for making REST calls across all developer-facing components in Zoho CRM. It is currently supported in Widgets and CScript, and will soon be available for other features within the Developer Hub as well.

It simplifies external API usage with:
  1. async/await support
  2. Auto JSON parsing
  3. Unified API client for Zoho CRM developer tools (currently supported for CScript and widgets)
  4. Stronger error handling

Business Problem

Zylker, a real-estate company, stores documents, images, and property videos for each lead in a third-party cloud storage platform. 

However, some of these files exceed 20 MB, making the CRM’s built-in file upload field unsuitable. Their team also needs the ability to preview and upload files directly from the Lead detail page.

Solution Overview

Zylker can build a Related List Widget integrated with their third-party cloud storage platform using ZRC methods.

This widget will allow users to:
  1. Fetch and display files inside the folder linked to the Lead.
  2. Preview files (images, PDFs, videos) inside the widget.
  3. Upload new documents to the same folder.
  4. Create new subfolders to keep the data organized. 
  5. Navigate subfolders using breadcrumbs. 
To keep the demo simple, let us walk you through on building this widget for listing, previewing and uploading files using Zoho WorkDrive. 

Prerequisites

1. Create a Custom Field

Create a Single Line field named WorkDrive Folder ID in the Leads module. Check out the Working with Custom Fields document for guidance.

This stores the folder ID created for each lead through workflow rule that we build in the next steps.

2. Create WorkDrive and CRM Connection

  1. Go to Setup > Developer Hub > Connections and click Create Connection. 
  2. Choose Zoho WorkDrive with the scopes WorkDrive.files.CREATE and WorkDrive.files.READ. 
  3. Click the Create and Connect button and proceed to authorize the connection.

  1. Similarly, choose Zoho CRM with the ZohoCRM.modules.ALL scope and create the connection.
Refer to the Connections help doc for more information. Store the Connection Link Name to use while making API calls. 

3. Automate WorkDrive Folder Creation

  1. Go to Automation > Workflow Rules in the Setup page and click Create Rule. 
  2. Create a Workflow Rule with the following details:
Module: Leads
Trigger: On Record Creation
Condition: All Records
Action: Custom Action (Deluge Function)


Function Logic:

1. Create a new folder in the WorkDrive combining the lead's record ID and First Name as the folder's name. Use the Invoke URL task to make the Create Folder API call. 

responseMap = Map();
attributeInfo = Map();
dataInfo = Map();
headerMap = Map();
headerMap.put("Accept","application/vnd.api+json");

// First Name and Record ID from the argument

AttributeInfo.put("name",Name + recordId);

// Parent folder ID under which you want to maintain the lead folders

attributeInfo.put("parent_id","e8gn06f2d7b3a48044090b7217524be95c9ac");
dataInfo.put("attributes",attributeInfo);
dataInfo.put("type","files");
responseMap.put("data",dataInfo);
folderCreateResponse = invokeurl
[
url :"https://zohoapis.in/workdrive/api/v1/files"
type :POST
parameters:responseMap.toString()
headers:headerMap
        connection:"workdrive_oauth_connection" // Connection Link Name created in the prerequisites  
];
info folderCreateResponse;

2. Retrieve the folder ID from the API response.

3. Update the Lead’s WorkDrive Folder ID field with this folder ID using Update Records API call. 

requestBody = Map();
dataList = List();
record = Map();

// Set field values

record.put("WorkDrive_Folder_ID",driveId);

// Add record to list

dataList.add(record);

// Wrap data

requestBody.put("data",dataList);
updateLead = invokeurl
[
url :"https://zohoapis.in/crm/v8/Leads/" + recordId
type :PUT
parameters:requestBody.toString()
connection:"crm_oauth_connection"
];
info updateLead;

Assign values to the arguments using merge fields while associating the function with Workflow Rule.



Now every Lead has its own WorkDrive folder before the widget loads. 

Notes
Note:

The complete code snippet for the deluge function is attached to the post for your reference. 

Building the Related List Widget

Step 1: Initialize the Widget Project

Review the basics from our earlier Kaizen on CLI Installation, Creating a Widget Project, and Internal hosting of the same.

Step 2: Develop your Widget

After setting up the widget project using CLI, implement the following code logic for the case we are discussing:
  1. Get the current record's ID from the PageLoad event. 
  2. With the record ID, fetch the lead details using the GET Records API call using the GET ZRC method as shown here. 
// data.Entity and data.EntitiyId are the module and record ID from PageLoad
const response = await zrc.get(
      "/crm/v8/" + data.Entity + "/" + data.EntityId
    );
 var workdriveFolderId = response.data.data[0].WorkDrive_Folder_ID;
  1. Extract the WorkDrive Folder ID from the response to get the list of files from the folder. 
  2. Since we'll be using WorkDrive APIs multiple times, let’s create a reusable instance with the Connection Link Name and API's base URL. This way, we avoid repeating the same setup for every API call.
Following is sample of how to create a custom instance:

workDriveZrc = zrc.createInstance({
    baseUrl: "https://www.zohoapis.in/workdrive/api/v1",
    connection: "workdrive_oauth_connection",
 });

You can also check out the Create Instance in the requestConfig help section to learn more. 
  1. Now, let us make the GET List of Files/Folder API call using the newly created ZRC instance.  
let apiResponse = await workDriveZrc.get(
        "/files/" + workdriveFolderId + "/files",
        {
          headers: {
            Accept: "application/vnd.api+json",
          },
        }
 );
  1. Display the file details like File Name, Type and Modified Time in a table from the API response. Save the File ID in a variable for displaying preview. 
  2. When user clicks a particular file, use the file ID to fetch the preview URL using the GET Preview Meta Data API. Then load the preview URL in an iframe to display the file. 
try {
      const previewResponse = await workDriveZrc.get(
        "/files/" + resourceId + "/previewinfo",
        {
          headers: {
            Accept: "application/vnd.api+json",
          },
        }
      );
      parsed = JSON.parse(previewResponse.data);
      console.log("Preview Data:", parsed);

      // Extract the preview_url from the expected location

      previewUrl = parsed && parsed.data && parsed.data.attributes && parsed.data.attributes.preview_url || null;

      // Remove surrounding quotes if server wrapped the url in quotes

      if (typeof previewUrl === "string") {
        previewUrl = previewUrl.replace(/^"(.*)"$/, "$1").trim();
      }
    } catch (err) {
      console.error("Error fetching preview info for resource:", resourceId, err);
 }
function showPreview(previewUrl, fileName, permalink) {
  var modal = document.getElementById("modal-container");
  var thumbnailFrame = document.getElementById("thumbnail-img");
  var caption = document.getElementById("caption");
  var workdriveLink = document.querySelector(".redirect-workdrive");

  // Load the preview URL into the iframe

  thumbnailFrame.src = previewUrl;

  // Set the file name in caption and workdrive link

  caption.textContent = fileName;
  workdriveLink.setAttribute("data-link", permalink);

  // Show the modal

  modal.style.display = "block";
}
  1. Create an Upload button for users to select files from their local. Convert the streamed files to blob and execute Upload API call using the custom ZRC instance. 
async function workdriveUpload(file, fileType, fileName, folderId) {
  const fileBlob = new Blob([file], { type: fileType });
  try {
    const formData = new FormData();
    formData.append("filename", fileName);
    formData.append("parent_id", String(folderId).trim());
    formData.append("content", fileBlob);
    const uploadResponse = await workDriveZrc.post(
      "/upload", formData,
      {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      }
    );
    console.log("Upload response:", uploadResponse.data);
    return uploadResponse;
  }
  catch (error) {
    console.error("Error uploading file:", error);
    throw error; 
  }
}

Step 3: Validate and Pack

Follow the steps given in the Widget help page to validate and package the widget.

Step 4: Upload to Zoho CRM

  1. Go to Zoho CRM > Setup > Developer Hub > Widgets and click Create New Widget.
  1. Fill in the required details such as:
Name: Zoho WorkDrive
Type: Related List 
Hosting: Zoho 
File Upload: Upload the ZIP created in the dist folder within the widget project directory after packaging in the Step 3. 
Index page: /widget.html
  1. Create a related list in the Leads module and associate this widget. Refer to the Customize Related Lists help page for more information on creating a related list.

Try it Out!

A complete working code sample of this widget is attached at the bottom of this post for reference. 

Now let us see how this works from the Lead's detail page:

1. Listing the available files from Zoho WorkDrive on page load. 


2. Uploading new files to the folder.


3. Previewing all the listed files.


We hope this Kaizen helps you explore the new ZRC capabilities and build seamless file-management experiences in Zoho CRM.

Have questions or suggestions? Drop them in the comments or write to us at  support@zohocrm.com. 

We will circle back to you next Friday with another interesting topic. 

On to Better Building!

------------------------------------------------------------------------------------------------------

Related Reading

2. Connections - An Overview
4. CRM APIs - GET Records and Update Records 
6. CRM Customizations - Related Lists and Custom Fields.
------------------------------------------------------------------------------------------------------

Idea
Previous Kaizen: Client Script Support for Notes Related List | Kaizen Collection: Home


    • Sticky Posts

    • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

      We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
    • Kaizen #261 : Using Zoho CRM Skill to generate complex COQL queries

      Hello everyone, In the previous Kaizen posts, we introduced the zoho-crm SKILL.md and discussed how it can help you when you are working with Zoho CRM APIs and Client Script. In this Kaizen, we will focus on using the Zoho CRM `SKILL.md` with GitHub Copilot
    • Kaizen #256 - Build an Arrival Readiness Web Tab in Zoho CRM

      Hi everyone! Welcome back to the Kaizen series! In the post, we discuss a use case in hospitality industry: how an Arrival Readiness web tab widget can be used to let reception staff identify and resolve issues before arrival of guests. Use case In the
    • 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.
    • Kaizen #226: Using ZRC in Client Script

      Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this

    Nederlandse Hulpbronnen


      • Recent Topics

      • How To Implement an Auto-Check-out Feature for Attendance?

        If an employee forgets to check out, the system should automatically check out the employee at 6:30 PM
      • WorkDrive Desktop Sync Is Being Deprecated: Move to WorkDrive TrueSync for a Smarter Experience

        Hi everyone, We are excited to share a better, smarter way to access and manage your files directly from your computer! We’re transitioning from our legacy Desktop Sync app to WorkDrive TrueSync, designed to give you faster performance,greater flexibility,
      • Bookings Notifications for Staff

        Good afternoon.  We are currently working on the trial version of Bookings as we review its usage for our client needs to schedule with specific team members.  We set everything up and it appears to be working, with the exception of sending an email to
      • Is COQL known to have read delays?

        Hello, I'm experiencing stale data returned by COQL from time to time. Most of the time it returns up-to-date data right after I update a record, but sometimes the change only shows up after several seconds or even minutes. Neither the COQL documentation
      • #18 Billing for the Hours, Not the Job

        A consultant in the comments last month put it plainly: her client pays by the hour and wants to see every hour on the invoice, including the dates. She was maintaining a spreadsheet and manually copying the totals into her invoices. If you bill by the
      • WhatsApp con bot en Make y derivación a una persona en Zoho CRM

        Estamos implementando en Zoho CRM un flujo de atención por WhatsApp con un bot en Make y una derivación a una persona. Necesitamos que cada mensaje quede registrado, que me avise cuando requiere atención y poder seguir la misma charla con el cliente.
      • Webhooks for Bigin

        Hello everyone, Say hello to webhooks in Bigin—a way to send information to other applications automatically the moment something happens to a record. Whether it's a deal moving stage, a contact being created, or a field changing, Bigin can now send an
      • Giving someone access to my FSM to develop + scope.

        Good evening, I’m new to Zoho, and had a CRM/Creator customized and it was missing something and not working. I realized it’s the functions and process and FSM was the missing link. I am trying to get FSM setup and all I have to do connect to CRM, Books,
      • Set Custom Icon for Custom Modules in new Zoho CRM UI

      • Reassign a team member's follow-up tasks without moving their customers | Kiosk Studio Session #13

        Hello folks, It's almost year-end, and a lot of people on your team will take time off. Their customers will still need things while they're away. Say Amanda is out next week (on leave). She has a renewal purchase order to chase for Grace, a quote Vikram
      • WorkDrive and CRM not in sync

        1/ There is a CRM file upload field with WorkDrive file set as the source: 2/ Then the file is renamed in WorkDrive (outside CRM): 3/ The File in CRM is not synced after the change in WorkDrive; the file name (reference) in CRM record is not updated (here
      • Short product videos on Zoho Commerce product pages: what works?

        Short product videos are becoming a normal part of online store pages, and I have been thinking about how to use them well on a Zoho Commerce store. A few points that seem to matter: Keep them short. 6 to 15 seconds showing the product from a few angles
      • Error AS101 when adding new email alias

        Hi, I am trying to add apple@(mydomain).com The error AS101 is shown while I try to add the alias.
      • Meet the new Zoho Analytics: The Agentic Analytics platform

        Every major release of Zoho Analytics has changed what you can do with data. This one changes who does the work. For years, analytics meant a chain of hands. The engineer shaped the data, the analyst wrote the query, the designer built the dashboard,
      • Function failure APIs report "no failures" (204 / empty 200) while the Failures view lists real failures

        We want to monitor custom-function failures through the API so we can find and re-run failed functions quickly. We could not find a function-failures endpoint in the API reference (only webhook failures are documented), so we tried the paths that exist
      • Zoho Writer workflows now support custom stages, parallel reviews, and external approvers

        Hello everyone, Zoho Writer now lets you build your own approval chains. The pre-built workflows also get new review modes, completion criteria, and external approver support. What’s new Custom workflows: Design review and approval processes from scratch,
      • Unlock more with Linkthread's new Basic plan

        Hey everyone, Last year, we introduced Linkthread by Zoho Social with a simple idea: help users bring everything they want to share into one link. Since then, Linkthread has continued to evolve, and we’re excited to announce its next milestone—the launch
      • Rating system button not translated to Spanish + "Done"

        I've run into a issue with the new system for rating support interactions when the chat is ended: Missing Spanish translation: The button is still showing in English as "Done," even though the interface language is set to Spanish. It should display something
      • 【11/19(木)15時〜・先着5名】後回しになっているZohoの設定、一緒に進めませんか?|オンラインもくもく会

        ユーザーの皆さま、こんにちは。 コミュニティグループの中野です。 「試したい機能や設定があるけれど、日々の業務で後回しになっている」 「一人で検証していると、途中で手が止まってしまう」 「ほかのユーザーがどう運用しているか、聞いてみたい」 そんな方に向けて、11月19日(木)にオンラインの「Zoho ワークアウト」を開催します。 参加者それぞれが取り組みたいテーマを持ち寄り、設定・検証・運用改善を進める少人数の「もくもく会」です。 各自で作業しながら、必要に応じてユーザー同士で相談や情報交換ができます。
      • Connection into Cliq?

        I have the SalesIQ chat widget on my site using the Zohobot but I'm not always on and my employees don't keep it open all the time. We do have Cliq open all the time though so I'd love a way to manage those discussions directly in Cliq as they come in.
      • Multiple Topics assigned to a single Campaign

        Hello, is it possible to assign multiple Topics to a single Campaign? We frequently write a content to our subscribers that spans multiple Topics and we would like to send it to all Contacts that are subscribed to at least one of the Topics. But it looks
      • How to sync Organisation Contacts to Android / AES

        After migration form Exchange compatible server, I got Org Contacts: I've turned on EAS Organisation contacts sync. But on my phone they don't appear and there is no contacts folder to select for these contacts. Only personal contacts. They do appear
      • Zoho Campaigns - Accept Rollup Summary As Format In Use

        Hi Zoho Team, I would like to request an enhancement to the integration between Zoho CRM and Zoho Campaigns. Currently, Rollup Summary fields in Zoho CRM are available for selection during field mapping, but I am unable to map a Rollup Summary field containing
      • Is it possible to change the percentage field in zoho crm , to put 3 decimals ?

        Hello , I need to write 1,444 in the percentage field in zoho CRM. However, I've noticed that there is a limitation of 2 decimals for this field. I've found out that if I replace this field with a Decimal one (.OO), I can choose to have 3 decimals. I've
      • Save hours daily this peak season: Better Inventory & Shipping with Zoho on Easyship

        Peak season shouldn't mean losing control of your inventory just to keep up with demand. When the holiday rush hits, everything in your business gets tested at once. Orders surge, stock runs low, and shipping costs climb as customers expect faster delivery
      • How Can Zoho Desk and Knowledge Base Help Manage Technical Support for an Android TV Website?

        Hello everyone, I manage MXL TV App, an independent technology website covering Android applications, Android TV, Smart TVs, digital entertainment, installation guides, and troubleshooting. I'm exploring ways to organize technical questions and make helpful
      • Build a Legacy of Support with Zoho Desk

        Hi everyone, World Heritage Day, also known by the name International Day for Monuments and Sites, is a moment to celebrate the stories, culture, and history preserved in the monuments, landscapes, and heritage around us. At Zoho Desk, heritage is not
      • Documents greater than 40MB Preview

        hello, Documents bigger than 40 MB cannot be previewed in WorkDrive Web App or Mobile App. would it be resolved in future?
      • Issues with Zoho Sheet in Mac

        I have downloaded the Zoho App from App Store but It is failing to Save As, Open & Download Operations. App Store
      • To-do lists screwed up by update

        My app just updated, and now it's unusable for my grocery and packing lists and pretty much everything I use this app for. It used to be that when you checked a box on a to-do list, the item was automatically migrated to the bottom of the list. Then when
      • Campaign send from unverified e-dress

        L.S. I have a problem with z-Campaigns. My email (sender) address seems to be unverified: Verified domain. Sender couldn’t be verified This email is from your organization’s verified domain, but the sender couldn’t be verified. It may be an automated
      • Change default "Sort by"

        Is there a way to change the default "sort by" when searching across modules?" in Zoho CRM? Currently the default sort method is "Modified time" but i would like to utilize the second option of "relevance" as the sort by default and not have to change
      • New Search Function

        Hey Team, The search function updated in our CRM about a week ago, so I assume it was an automated update across Zoho. It no longer displays leads/deals etc in Chronological order so that the most recently created or updated is the first to display which
      • Large List on Sub-Forms

        Hi, I would like to be able to add and use the Large List on a Sub-Form, currently it doesnt appear to show up for Sub-Forms. Thanks Dan
      • Feature Request: Post-commit Subform Row Event (onRowSave / afterRowCommit) in Client Scripts

        Hello Zoho CRM Product & Engineering Team, Requested Feature: Introduce an afterRowCommit (or post-commit onRowSave) subform event in Client Scripts that fires immediately after an inline subform row has been successfully committed to the database, passing
      • #CyberSecurityAwareness - Be diligent when it comes to Widget security

        We love Widgets in Zoho CRM! And in our experience they have become an essential tool for extending the feature set and providing a rich user experience beyond standard CRM UI, functionality and integrations. BUT BEWARE... If you are thinking of adding
      • Introducing the Zoho Campaigns MCP server

        Hello everyone, We are pleased to announce that Zoho Campaigns is now available in Zoho MCP. You can now connect your Zoho Campaigns organization to AI tools such as Claude, ChatGPT, GitHub Copilot in VS Code, and Cursor, and manage your email marketing
      • Deluge {"trigger":{"workflow"}} Do we need to add the id of rules of functions or rules in the workflow ?

        Hello , I've user {"trigger":{"workflow"}} in Deluge language. In my Deluge code, in order to trigger the workflow, I've specified the id of the workflow, of the rules and of the function called by the workflow. However, Zoho CRM told me that it was not
      • Let’s Talk Recruit: Answering your hiring review’s top five questions

        Picture this, it's the final week of the month, and your hiring review is just around the corner. You already know the questions you'll be asked. Which roles have been open the longest? Why did the Product Designer pipeline go quiet after the second interview?
      • What's New in Zoho POS - October 2026

        Hello everyone, Welcome to Zoho POS’s monthly update, where we bring you the latest feature releases, enhancements, events, and more. Let’s take a quick look at the new item price override option for embedded barcodes and how it can help streamline your
      • Next Page