Displaying Subform Information as a Custom Related List in Zoho CRM  

Zoho CRM’s flexibility allows you to enhance your customer relationship management by customizing how data is displayed and accessed. One powerful customization option is the ability to display subform information from related records as a custom related list in Zoho CRM. This can be particularly useful when dealing with complex data structures, such as managing license keys tied to entitlements.

In this post, we’ll walk through the process of fetching related records from a subform, processing the data, and displaying it as a custom related list in Zoho CRM.

Understanding the Scenario  

Imagine you have a module in Zoho CRM called “Entitlements” that contains a subform for “License Keys.” Each license key may contain information such as product name, number of users, expiration date, and more. To make this information easily accessible, you want to display all related license keys as a custom related list within the “Entitlements” record.

Here’s how to achieve this:

Step 1: Fetch Related Records  

The first step is to retrieve all related license records associated with a particular entitlement. This can be accomplished using Zoho CRM’s getRelatedRecords API function.

relatedLicenses = zoho.crm.getRelatedRecords(“License_Keys”, “Entitlements”, ENT_ID);
info “relatedLicenses is ” + relatedLicenses;

In this code snippet, getRelatedRecords is used to fetch all license records related to the entitlement identified by ENT_ID. The retrieved data is stored in the relatedLicenses variable.

Step 2: Process the Retrieved Data  

Once you have the related license records, the next step is to process the data. For each license, you may need to extract additional details such as product name, number of users, expiration date, and more.

returnList = List();

if(relatedLicenses.size() > 0)
{
    for each license in relatedLicenses
    {
        licenseID = license.get(“id”);
        licenseRecord = zoho.crm.getRecordById(“License_Keys”, licenseID);
        keyData = licenseRecord.get(“Keys”);

        if(keyData.size() > 0)
        {
            for each key in keyData
            {
                // Extract relevant fields from the key data
                Product = key.get(“Product”).get(“name”);
                Number_of_Users = ifnull(key.get(“Quantity”), “-“);
                Computer_Server_Name = ifnull(key.get(“Computer_Server_Name”), “-“);
                Host_Server_Code = ifnull(key.get(“Host_Server_Code”), “-“);
                Expiration_Date = ifnull(key.get(“Expiration_Date”).toString(), “-“);
                License_Key = ifnull(key.get(“License_Key”), “-“);

                // Create a URL that links to the specific license record in CRM
                url = “https://crm.zoho.com/crm/orgxxxxxxx/tab/CustomModule1/” + licenseID;

                // Format the return value as an XML-like structure containing the license information
                returnValue = ‘<record><row no=”0″><FL link=”true” url=”‘ + url + ‘” val=”License Name”>’ + licenseName + ‘</FL><FL val=”Product”>’ + Product + ‘</FL><FL val=”Number of Users”>’ + Number_of_Users + ‘</FL><FL val=”Computer Name”>’ + Computer_Server_Name + ‘</FL><FL val=”Host Server Code”>’ + Host_Server_Code + ‘</FL><FL val=”Expiration Date”>’ + Expiration_Date + ‘</FL><FL val=”License Key”>’ + License_Key + ‘</FL></row></record>’;
                
                // Add the formatted return value to the return list
                returnList.add(returnValue);
            }
        }
    }
}

Here, the code iterates through each related license, extracting and formatting the necessary fields. The formatted data is then stored in a list (returnList) that will be used to create the custom related list.

Step 3: Handling Missing Data  

In some cases, a license might not have associated key data. You can handle these situations by providing default values for missing fields.

else if(keyData.size() == 0)
{
    url = “https://crm.zoho.com/crm/orgxxxxxxxxx/tab/CustomModule1/” + licenseID;
    returnValue = ‘<record><row no=”0″><FL link=”true” url=”‘ + url + ‘” val=”License Name”>’ + licenseName + ‘</FL><FL val=”Product”>’ + “-” + ‘</FL><FL val=”Number of Users”>’ + “-” + ‘</FL><FL val=”Computer Name”>’ + “-” + ‘</FL><FL val=”Host Server Code”>’ + “-” + ‘</FL><FL val=”Expiration Date”>’ + “-” + ‘</FL><FL val=”License Key”>’ + “-” + ‘</FL></row></record>’;
    returnList.add(returnValue);
}

This ensures that even if certain data is missing, the related list will still display a complete row with placeholder values.

Step 4: Returning the Final Data  

Finally, once all the data has been processed, you return the list of formatted license information.

info returnList;
return returnList;

This list will be displayed as a custom related list in the CRM, making it easy for users to view all related license information directly within the entitlement record.

Conclusion  

Displaying subform information as a custom related list in Zoho CRM is a powerful way to enhance data accessibility and user experience. By following the steps outlined in this guide, you can easily fetch, process, and display related records, providing your team with quick access to essential data.

Implementing this approach in your Zoho CRM environment will not only streamline your workflows but also ensure that all relevant information is readily available where it’s needed most. Whether you’re managing license keys, contracts, or any other related data, this method will help you keep everything organized and accessible.