Related Lists APIs
A record usually contains additional information such as notes, attachments, products, deals, contacts, etc. Using related lists API, you can retrieve all the related list information.
Get Related Records
Purpose
To get the related list records.
Request URL
https://www.zohoapis.com/crm/v2/{module_api_name}/{record_id}/{related_list_api_name}
module_api_name - The API name of the module
record_id - Unique ID of the record
related_list_api_name - The API name of the related list. To get the API name of the related list, see Related Lists Meta Data
| Supported relations |
|---|
| Campaigns - to - Leads, Contacts Products - to - Leads, Accounts, Contacts, Potentials, Price Books |
Request Method
GET
Scope
scope=ZohoCRM.modules.all
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}
| Possible module names | Possible operation types |
|---|---|
| leads, deals, contacts, accounts, products, campaigns, and pricebooks | ALL - Full access to related records WRITE - Edit related records DELETE - Delete related records |
The page and per_page parameter is used to fetch records according to their position in the CRM. Let's assume that the user has to fetch 400 records. The maximum number of records that one can get for an API call is 200. So, for records above the 200th position, they cannot be fetched. By using the page (1, 2, 3 and 4) and per_page (100) parameter, the user can fetch all 400 records using 4 API calls.
Request Headers
| Header name | Data Type | Description | Example |
|---|---|---|---|
| If-Modified-Since (optional) | DateTime(ISO 8601 format) | To get the list of recently modified records | 2019-07-25T15:26:49+05:30 |
Possible Errors
| HTTP Status | Error Code | Message | Reason |
|---|---|---|---|
| 400 | INVALID_DATA | The relation name given seems to be invalid | If the RelatedModule or RelatedAPIName is invalid |
Sample Request
curl "https://www.zohoapis.com/crm/v2/Leads/410888000000698006/Notes"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf" Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
} Sample Request
ZCRMRecord record = ZCRMRecord.getInstance("Contacts", 12345l);//module api name with record id
BulkAPIResponse response = record.getRelatedListRecords("Deals");
List<ZCRMRecord> deals = (List<ZCRMRecord>) response.getData(); //relatedList name Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
} Sample Request
$zcrmRecordIns = ZCRMRecord::getInstance(“Products", 410405000001108011);
$bulkAPIResponse=$zcrmRecordIns->getRelatedListRecords(“Deals”);
$relatedRecordsList=$bulkAPIResponse->getData(); // $relatedRecordsList - array of ZCRMRecord instances which are related to given Product. Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
} Sample Request
def get_related_records(self):
try:
record = ZCRMRecord.get_instance('Leads', 3719520000000323002) # module API Name, entityId
resp = record.get_relatedlist_records('Products') # related list API Name
print(resp.status_code)
record_ins_arr = resp.data
for record_ins in record_ins_arr:
print(record_ins.entity_id)
print(record_ins.owner.id)
print(record_ins.created_by.id)
print(record_ins.modified_by.id)
print(record_ins.created_time)
print(record_ins.modified_time)
print(record_ins.get_field_value('Product_Name'))
print(record_ins.get_field_value('Product_Code'))
print(record_ins.get_field_value('Vendor_Name'))
print(record_ins.get_field_value('Commission_Rate'))
print(record_ins.get_field_value('Qty_in_Demand'))
print(record_ins.get_field_value('Tax'))
print(record_ins.get_field_value('Unit_Price'))
print(record_ins.get_field_value('Reorder_Level'))
print(record_ins.get_field_value('Usage_Unit'))
print(record_ins.get_field_value('Qty_Ordered'))
print(record_ins.get_field_value('Qty_in_Stock'))
print(record_ins.get_field_value('Sales_Start_Date'))
print(record_ins.get_field_value('Sales_End_Date'))
print(record_ins.get_field_value('Taxable'))
print(record_ins.get_field_value('Support_Expiry_Date'))
print(record_ins.get_field_value('Manufacturer'))
print(record_ins.get_field_value('Description'))
print(record_ins.field_data)
print("\n\n")
except ZCRMException as ex:
print(ex.status_code)
print(ex.error_message)
print(ex.error_code)
print(ex.error_details)
print(ex.error_content) Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
} Sample Request
Syntax:
zoho.crm.getRelatedRecords(<module String>,<parentModuleName String>,<recordId Long>,<page Long>,<perPage Long>,<connectionName String>,<userAccess Boolean>);
mandatory : module,parentModuleName,recordId
Sample Request:
resp = zoho.crm.getRelatedRecords("Related_List_Name_2","Leads","7000000037002"); Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
} Sample Request
ZCRMRecord recordIns= ZCRMRecord.GetInstance("Leads", 3372164000000); //module api name with record id
BulkAPIResponse<ZCRMRecord> response = recordIns.GetRelatedListRecords("Products"); //RelatedList api name
List<ZCRMRecord> relatedRecordsLists = response.BulkData; //relatedRecordsLists - list of ZCRMRecord instance Sample Response
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}