Groups

A group is a collection of items in a portal.

Working with groups

Groups are used to organize and share items and define which users can access and view the content. You can create groups of hosted layers, web maps, or any other item type. Or you can create a group and add users to it, allowing them to collaborate and share items within the group.

The typical workflow for using groups is to:

  1. Define a group in a portal.
  2. Add items the group.
  3. Add users to the group.
  4. Manage the group properties.

Examples

Search for a group

Find a one or more groups in a portal using a query.

    
import { searchGroups } from "@esri/arcgis-rest-portal";
// Find groups with text
searchGroups('water')
  .then(response) // response.total => 355

Create a new group

Define a new group and how it can be accessed.

          
import { createGroup } from "@esri/arcgis-rest-portal";
// Create a new public group
createGroup({
  group: {
    title: "Traffic issues",
    access: "public"
  },
  authentication
})
  .then(response)

Invite users to a group

Invite users by their user names.

                    
const authentication: IAuthenticationManager; // Typically passed into to the function
// Send invitations
const options: IInviteGroupUsersOptions = {
 id: 'group_id',
 users: ['ed', 'edd', 'eddy'],
 role: 'group-member',
 expiration: 20160,
 authentication
}
// Wait for results
const result = await inviteGroupUsers(options);
// Accepted
const if_success_result_looks_like = {
 success: true
}
// Declined
const if_failure_result_looks_like = {
 success: false,
 errors: [ArcGISRequestError]
}

Add items to a group

Add an item to group to be shared with a set of users.

        
import { shareItemWithGroup } from '@esri/arcgis-rest-portal';
// Add an item to a group
shareItemWithGroup({
  id: "abc123",
  groupId: "xyz987",
  owner: "some-owner",
  authentication
})

Search for group content

Find items shared with a group using a query.

    
import { searchGroupContent } from "@esri/arcgis-rest-portal";
// Find items that match in group
searchGroupContent('water')
  .then(response) // response.total => 355

Update properties

Change the properties of a group such as the name, description, and permissions.

      
import { updateGroup } from '@esri/arcgis-rest-portal';
// Update properties
updateGroup({
  group: { id: "fgr344", title: "new" }
})
  .then(response)

Tutorials