Get Departments
Table of Contents
Overview
The zoho.directory.getDepartments task is used to fetch all the departments within an organization.
Syntax
<response> = zoho.directory.getDepartments(<orgID>, <page>, <per_page>, <queryParams>, <connectionName>);
Scope
ZohoDirectory.Groups.READ
where:
Parameter | Description | Data type |
response | is the variable that will hold the details of the departments fetched from the organization. | KEY-VALUE |
<orgID> | is the ID of the organization from which the departments need to be fetched. | NUMBER |
<page> | To get the list of records based on pages. | NUMBER |
<per_page> | Maximum number of records (1-200) in a single page. | NUMBER |
<queryParams> | is the variable that holds the query parameters.
| KEY-VALUE |
<connectionName> | is the name of the Zoho Directory connection. | TEXT |
The below-mentioned parameters can be used in <queryParams>:
Supported Includes:
Parameters | Description |
Emails | Including emails will provide the entire department's email information in the response. |
Example 1: Fetch all departments from the specified organization
The following script fetches the first 200 departments from Zoho Directory organization:
response = zoho.directory.getDepartments(72XXXXXXX, "1", "200", Map(), "zoho_directory_connection");
where:
response
This is the KEY-VALUEresponse returned by Zoho Directory.
72XXXXXXX
This is the NUMBERthat represents the organization ID of Zoho Directory account from which the groups need to be fetched.
zoho_directory_connection
This is the TEXTthat represents the link name of the connection.
1
This is the NUMBERthat represents the index number of the first record that needs to be fetched.
200
This is the NUMBERthat represents the total number of records that need to be fetched.
Example 2: Fetch all departments from the specified organization with the use of Include
The following script fetches all the departments with email address included from Zoho Directory organization with the use of filters, and that includes:
queryParams = Map(); include = []; include.add("emails"); queryParams.put("include", include); response = zoho.directory.getDepartments(72XXXXXXX,"1", "200", queryParams, "zoho_directory_connection")
where:
emails
This is the TEXTthat represents the email addresses of users present in the department.
Response format
{
"status_code": 200,
"groups": [
{
"emails": [
{
"email_id": "K******@******.***",
"is_primary": true,
"is_alias": false,
"is_verified": true
}
],
"department_head": "79*************",
"deptHeadInfo": {
"user_id": "79*************",
"last_name": "******",
"primary_email": "N******@******.***",
"first_name": "N****"
},
"group_name": "D***********",
"group_id": "76*********",
"group_type": 1,
"created_by": "79*************",
"group_description": "De*******************"
},
{
"group_id": "76******",
"group_name": "K********",
"group_type": 1,
"created_by": "79*************",
"group_description": "K****************"
}
],
"has_more": false,
"resource_name": "groups"
}
"status_code": 200,
"groups": [
{
"emails": [
{
"email_id": "K******@******.***",
"is_primary": true,
"is_alias": false,
"is_verified": true
}
],
"department_head": "79*************",
"deptHeadInfo": {
"user_id": "79*************",
"last_name": "******",
"primary_email": "N******@******.***",
"first_name": "N****"
},
"group_name": "D***********",
"group_id": "76*********",
"group_type": 1,
"created_by": "79*************",
"group_description": "De*******************"
},
{
"group_id": "76******",
"group_name": "K********",
"group_type": 1,
"created_by": "79*************",
"group_description": "K****************"
}
],
"has_more": false,
"resource_name": "groups"
}