Get Groups for User

Table of Contents

Overview

The zoho.directory.getUserGroups task is used to fetch groups of a user using their ID within an organization.

Syntax

 <response> = zoho.directory.getUserGroups(<orgID>, <userID>,  <page>, <perPage>, <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
<connectionName>is the name of the Zoho Directory connection.TEXT
<userID>is the ID of the user for whom all groups 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

Example: Fetch groups of a user from the specified organization

The following script fetches all the groups of a user in Zoho Directory organization:

response = zoho.directory.getUserGroups(72XXXXXXX, 1510XXXXXXXX, "1", "200", "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.
zoho_directory_connection
This is the TEXTthat represents the link name of the connection.
1510XXXXXXXX
This is the NUMBERthat represents the user ID.
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 needs to be fetched.

Response format

{
    "status_code": 200,
    "groups": [
        {
            "group_id": "70******",
            "group_name": "Zo*****",
            "group_type": 0,
            "created_by": "790**************",
            "group_description": ""
        },
        {
            "group_id": "72******",
            "group_name": "K******",
            "group_type": 0,
            "created_by": "790*************",
            "group_description": ""
        },...
    ],
    "has_more": false,
    "resource_name": "groups"
}