Get Departments

Table of Contents

Note:

  • This task is applicable to all services except Zoho Creator.
  • Each time the zoho.one.getDepartments integration task is executed, it triggers an API request in the back-end. This call is deducted from the external calls limit available for the service from which the task is executed, based on your pricing plan.
  • Only actual executions that receive a response (whether success or failure) are counted, not the number of times the task appears in the script. For example, if zoho.one.getDepartments integration task is placed inside a for each task that iterates five times, the number of external calls consumed will be five, even though the task appears only once in the script. 

Overview

The zoho.one.getDepartments task is used to fetch all the departments within an organization.

Syntax

<response> = zoho.one.getDepartments(<orgID>, <page>, <per_page>, <queryParams>, <connectionName>);

Scope

ZohoOne.Groups.READ

where:

ParameterDescriptionData type
responseis 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.

  • Include
KEY-VALUE
<connectionName>is the name of the Zoho One connection.TEXT

The below-mentioned parameters can be used in <queryParams>:

Supported Includes:

ParametersDescription
EmailsIncluding 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 One organization:

response = zoho.one.getDepartments(72XXXXXXX, "1", "200", Map(), "zoho_one_connection");

where:

response
This is the KEY-VALUEresponse returned by Zoho One.
72XXXXXXX
This is the NUMBERthat represents the organization ID of Zoho One account from which the groups need to be fetched.
zoho_one_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 One organization with the use of filters, and that includes:

queryParams = Map();
include = [];
include.add("emails");
queryParams.put("include", include);
response = zoho.one.getDepartments(72XXXXXXX,"1", "200", queryParams, "zoho_one_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"
}