Get Groups

Table of Contents

Overview

The zoho.directory.getGroups task is used to fetch all the groups within an organization.

Syntax

<response> = zoho.directory.getGroups(<orgID>, <page> , <per_page>,  <queryParams>, <connectionName>);

Scope

ZohoDirectory.Groups.READ

Where:

ParameterDescriptionData type
responseis the variable which will hold the details of the groups fetched from the organization.KEY-VALUE
<orgID>is the ID of the organization from which the groups need to be fetched.NUMBER
<queryParams>

is the variable that holds the query parameters.

  • filters
  • Include
KEY-VALUE
<page>To get the list of records based on pages.NUMBER
<per_page>Maximum number of records (1-200) in a single page.NUMBER
<connectionName>is the name of the Zoho Directory connection.TEXT

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

Supported Includes:

ParametersDescription
EmailsIncluding emails will provide the entire group's email information in the response.

Example 1: Fetch all groups from the specified organization

The following script fetches the first 200 groups from Zoho Directory organization:

response = zoho.directory.getGroups(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 groups from the specified organization using "include"

The following script fetches the first 200 groups along with their email addresses from Zoho Directory organization using includes:

queryParams = Map();
filters = Map();
include = [];
include.add("emails");
queryParams.put("include", include);
response = zoho.directory.getGroups(72XXXXXXX,  "1", "200", queryParams, "zoho_directory_connection")

where:

emails
This is the VARIABLEthat represents the email addresses of users in the group that need to be fetched.
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.

Response format

{
    "status_code": 200,
    "groups": [
        {
            "emails": [
                {
                    "email_id": "N******@*******.***",
                    "is_primary": true,
                    "is_alias": false,
                    "is_verified": true
                }
            ],
            "group_id": "70*******",
            "group_name": "Zo******",
            "group_type": 0,
            "created_by": "79**************",
            "group_description": "D************"
        },
        {
            "group_id": "71*******",
            "group_name": "IA*******",
            "group_type": 0,
            "created_by": "79***************",
            "group_description": "G**************"
        }
    ],
    "has_more": false,
    "resource_name": "groups"
}