Choose where you’d like to start

Get related records from Zoho Desk

Overview

This task is used to fetch records from a submodule related to a record in a parent module in Zoho Desk.

Syntax

<variable> = zoho.desk.getRelatedRecords(<orgID>, <sub_module>, <parent_module>, <record_ID>, <fromIndex>, <limit>, <query_value>, <connection>);

where,

ParameterData typeDescription

<variable>

KEY-VALUE

variable which will hold the response returned by Zoho Desk. It represents the related records fetched from the specified submodule.

<orgID>

NUMBER

specifies the organization ID of the account from which the records will be fetched. This can be found in Zoho Desk Settings > Developer Space > API.  

<sub_module>

TEXT

specifies the name of the submodule from which the records will be fetched.

The zoho.desk.getRelatedRecords task allows you to fetch:

  • tickets based on a contact

  • tickets based on an account

  • tasks based on a ticket

  • timeEntry based on a ticket

  • timeEntry based on a task

  • timeEntry based on an agent

  • comments based on a ticket

  • thread based on a ticket

<parent_module>

TEXT

specifies the name of the module whose related records will be fetched.

<record_ID>

NUMBER

specifies the ID of the parent record.

Learn how to fetch the record ID after creatingsearching or fetching records.

<fromIndex>

(optional)

NUMBER

specifies the index number, starting from which the records will be fetched. 

 

*Note: This is a mandatory param when used in Zoho Creator.

<limit>

(optional)

NUMBER

specifies the number of records to be fetched.

 

*Note: This is a mandatory param when used in Zoho Creator.

<query_value>

(optional)

KEY-VALUE

specifies the query to include secondary information related to the selected module.

To learn about the applicable values, click here and go to <ModuleName> -> List <subModule> by <ModuleName>

*Note: This is a mandatory param when used in Zoho Creator.

<connection>

(optional)*

TEXT

specifies the name of the connection.

The scopes which need to be selected are:  
- Desk.basic.READ 
- Desk.tasks.READ 
- Desk.tickets.READ 
- Desk.settings.READ 
- Desk.contacts.READ 

*Note: This is a mandatory param when used in Zoho Creator.

Example 1

The following script fetches all the records from the submodule - tickets associated with the contact of record ID - 168XXXXXXXXXXXX043.

 queryValue = {"":""}; 
 response = zoho.desk.getRelatedRecords(641XXXXXX, "tickets", "contacts", 168XXXXXXXXXXXX043, 1, 10, queryValue, "desk_connection");

where,

response
variable which will hold the response returned by Zoho Desk. It represents the related records fetched from the specified submodule.
641XXXXXX
is the NUMBER that represents the organization ID
"tickets"
is the TEXT that represents the name of the related list
"contacts"
is the TEXT that represents the name of the module whose related records are to be fetched
168XXXXXXXXXXXX043
is the NUMBER that represents the ID of the parent record

Example 2

The following script fetches all the records from the submodule - timeEntry associated to the task with record ID - 168XXXXXXXXXXXX043. It sorts the records in descending order based on the the field - executedTime and returns 3 records starting from the index 1.

 queryValue = {"orderBy":"DESC"}; 
 response = zoho.desk.getRelatedRecords(641XXXXXX, "timeEntry", "tasks", 168XXXXXXXXXXXX043, 1, 3, queryValue, "desk_connection");

where,

"timeEntry"
is the TEXT that represents the name of the related list
"tasks"
is the TEXT that represents the name of the module whose related records are to be fetched
168XXXXXXXXXXXX043
is the NUMBER that represents the ID of the parent record
1
is the NUMBER that represents the start index from which the records are to be fetched
3
is the NUMBER that represents the number of records to be fetched
queryValue
is the KEY-VALUE variable that holds the query parameters
"orderBy"
is the TEXT that represents the query param as specified in Zoho Desk API
"desk_connection"
is the TEXT that represents the name of the connection.

Sample Response

Success Response

  • The success response returned is of the following format. It represents the values of the records fetched from the specified submodule (eg, tickets).

     {
     "data": [
     {
     "id": "168XXXXXXXXXXX043",
     "ticketNumber": "677",
     "email": "smith@gmail.com",
     "phone": "999999999",
     "subject": "Ticket subject 1",
     "status": "Open",
     "statusType": "Open",
     "createdTime": "2019-01-24T12:48:23.000Z",
     "priority": null,
     "channel": "Phone",
     "dueDate": "2019-03-21T16:16:16.000Z",
     "responseDueDate": null,
     "commentCount": "1",
     "threadCount": "120",
     "closedTime": null,
     "onholdTime": null
     "departmentId": "168XXXXXXXXXXXX044",
     "contactId": "168XXXXXXXXXXXX005",
     "productId": null,
     "assigneeId": "189XXXXXXXXXX001",
     "teamId": "892XXXXXXXXXX071",
     "webUrl": "https://desk.zoho.com/support/smith/ShowHomePage.do#Cases/dv/bf5c8f5ad85af0491d39fc24ba1e02adafb6719abeecaa48",
     "lastThread": null,
     "customerResponseTime": "2019-03-24T12:48:22.000Z"
     }
     {
     "id": "168XXXXXXXXXXXXX043",
     "ticketNumber": "678",
     "email": "zen@gmail.com",
     "phone": "1111111111",
     "subject": "Ticket subject 2",
     "status": "Closed",
     "statusType": "Closed",
     "createdTime": "2019-01-24T13:24:19.000Z",
     "priority": "High",
     "channel": "Phone",
     "dueDate": "2019-03-15T16:16:16.000Z",
     "responseDueDate": null,
     "commentCount": "1",
     "threadCount": "121",
     "closedTime": "2019-01-24T13:24:58.000Z",
     "onholdTime": null,
     "departmentId": "168XXXXXXXXXXXX044",
     "contactId": "168XXXXXXXXXXXX005",
     "productId": null,
     "assigneeId": "189XXXXXXXXXX007",
     "teamId": ""892XXXXXXXXXX072",
     "webUrl": "https://desk.zoho.com/support/zen/ShowHomePage.do#Cases/dv/bf5c8f5XXXXXXXXXXXXXXXXXXXXXXXXXXfb6719abeecaa48",
     "lastThread": null,
     "customerResponseTime": "2019-03-24T13:24:18.000Z"
     }
     ]
     }

Failure Response

  • The failure response returned for incorrect or non-existent organization ID is of the following format.

       {
       "errorCode":"UNPROCESSABLE_ENTITY",
       "message":"The value passed for the 'orgId' parameter is invalid."
       }
  • The failure response returned for an incorrect or non-existent record ID is of the following format.

       {
       "errorCode":"URL_NOT_FOUND",
       "message":"The URL you requested could not be found."
       }

Related Links

Get Started Now

Execute