Home / Zoho / SalesIQ / How to get any related list information in Zoho CRM using Deluge Script
SalesIQ | Zoho

How to get any related list information in Zoho CRM using Deluge Script

Check out my courses Learn Dialogflow ES and Learn Dialogflow CX if you would like to learn Dialogflow in depth. 

If you use Zoho CRM, you can actually get all the information associated with a given lead by following a simple script.

In my case, I am interested in getting information about Visits for users of my BotFlo app. You can follow this method and get the information for all the related lists associated with your lead (or contact, or account etc).

First, create a button for the Leads in the Details page. (If you are not sure how to do this, check out my Zoho CRM Crash course on Udemy). Here, the GetCustomActions button has been added to the Details page inside the Leads module.

The parameter which must be passed to the lead must be the lead’s record id.

Here is the Deluge script

visit_records = zoho.crm.getRelatedRecords('Visits_Zoho_Livedesk','Leads',record_id);
info visit_records;
for each  visit_record in visit_record
	visit_id = visit_record.get('id');
	action_info = zoho.crm.getRecordById("Visits",visit_id);
	info '------------------:Action Info:----------------';
	info action_info;
	actions_performed_info = zoho.crm.getRelatedRecords('Actions_Performed','Visits',visit_id);
	for each  action_performed_info in actions_performed_info
		info '------------------:Actions Performed Info:----------------';
		info action_performed_info;
return visit_records;

This script only shows you how to access the relevant information. You should of course modify it to make it do something useful for your use case.

As you can see, first we called zoho.crm.getRelatedRecords(‘Visits_Zoho_Livedesk’,’Leads’,record_id) and pass in the lead’s ID as the record. The record_id is the input parameter as you can see from the earlier screenshot.

How do I know that I should use Visits_Zoho_Livedesk?

Go to APIs inside Settings

Now click on the API Names tab

Click on the Leads module (which is the parent module for us)

Once you click on the Leads module, click on the Related List from the dropdown.

Get the appropriate API name (make sure to use the value on the right, which is the actual name, and not the one on the left, which is the user-friendly name).

In case you are wondering how I knew it was the Visits – Zoho Livedesk, you can actually get this information by looking at the Zoho CRM API call for getting the “metadata” of related lists

As you can see, whatever shows up as Visits – Zoho SalesIQ inside the CRM actually has an API name of Visits_Zoho_Livedesk

By the way, I could have gotten the API name of the SalesIQ Visits by simply looking at the JSON data in the last screenshot. But what I am explaining here is multiple ways to confirm and verify that you are on the right track. This is quite important in Zoho – the documentation is often all over the place, so it is best that you find different ways of getting to the same information as a way to cross-verify what you are doing.

So we know that the outer API call is correct.

However, we also would like to see individual Actions for each Visit. When you click on one of the Visits, you notice two things. The tab on the top changes to “Visits”, and there is a list of entries corresponding to each page which was visited.

Here is the actual list of actions performed. As you can see, you have three actions. There are 4 column names – Action Type, Actions, Time Spent and Action Performed Time. We would like to also drill down into each of these list items and get their information.

So a couple of things have become clear – the “parent” module is now “Visits” and not “Leads”. And we need to find a related list

Important: note that the screenshot tells us that the information we are looking at is actually a Related List of the Visits module. To the best of my understanding, you can use this structure to infer pretty much ALL the information associated with a given record in Zoho CRM.

Follow this simple algorithm:

1 Do I need information about the current record, or a related record?

2 If it is a related record, what is the API name to use inside getRelatedRecords method?

3 To drill down further into the related record, go back to Step 1 🙂

Now back to our discussion. We want to find the API name for the Actions Performed related list.

Inside the API names settings, go to Visits.

Get the API names of all the related lists for Visits.

We can see that the API name we are looking for is Actions_Performed under the Visits module.

To verify, I sent another request to the Zoho CRM API using a curl request (I also explain how to set this up in my Zoho CRM Crash Course) and received the following information for the Visits module.

    "related_lists": [
            "sequence_number": "1",
            "display_label": "Attachments",
            "api_name": "Attachments",
            "module": "Attachments",
            "name": "Attachments",
            "action": null,
            "id": "4570699000000285304",
            "href": "Visits/{ENTITYID}/Attachments",
            "type": "default"
            "sequence_number": "2",
            "display_label": "Notes",
            "api_name": "Notes",
            "module": "Notes",
            "name": "Notes",
            "action": null,
            "id": "4570699000000285307",
            "href": "Visits/{ENTITYID}/Notes",
            "type": "default"
            "sequence_number": "3",
            "display_label": "Actions Performed",
            "api_name": "Actions_Performed",
            "module": "Actions_Performed",
            "name": "Actions Performed",
            "action": null,
            "id": "4570699000000287861",
            "href": "Visits/{ENTITYID}/Actions_Performed",
            "type": "default"

So we have now cross verified that Actions_Performed is indeed the API name we are interested in.

Interested side note: the Visits module isn’t even mentioned as one of the modules available for the API call in the Zoho documentation. Clearly their API documentation needs some work. 🙂

The BotFlo app gives you many tools which can speed up your Dialogflow bot development

This website contains affiliate links. See the disclosure page for more details. 
"The magic key I needed as a non-programmer"

The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn.

- Kathleen R
Cofounder, gathrHealth
Check out my YouTube courses

Dialogflow CX Beginner Tutorial

Dialogflow ES vs CX using a Decision Tree Bot

Intro to NLU for technical non-programmers

Better Dialogflow ES Bots Using the CTFS Framework

Search the autogenerated transcripts of all my YouTube videos
In this free course, I provide some tips for managing large Dialogflow ES bots without compromising on accuracy.

Similar Posts