# Team Sharing Technical Reference

Canonical page: https://www.adaptabletools.com/docs/technical-reference-team-sharing

## Team Sharing Event

AdapTable fires the `TeamSharingEntityChanged` Event whenever an [Active Shared Entity](https://www.adaptabletools.com/docs/handbook-team-sharing-active/index.md) is synchronised.

### TeamSharingEntityChangedInfo

The [`TeamSharingEntityChangedInfo`](https://www.adaptabletools.com/docs/reference/teamsharingentitychangedinfo.md) object provided by the event contains a single `sharedEntity` property:

| Property | Type | Description |
| --- | --- | --- |
| [sharedEntity](https://www.adaptabletools.com/docs/reference/teamsharingentitychangedinfo.md#sharedentity) | [`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md) | Shared entity whose revision changed. |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/teamsharingentitychangedinfo.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

It is of type [`sharedentity`](https://www.adaptabletools.com/docs/reference/sharedentity.md) which provides very full details of what is shared and when and how it was updated:

| Property | Type | Description |
| --- | --- | --- |
| [ChangedAt](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#changedat) | `number` | Last time when the object was changed |
| [ChangedBy](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#changedby) | `string` | Last User who changed the object |
| [Description](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#description) | `string` | Description of object being shared |
| [Entity](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#entity) | [`AdaptableObject`](https://www.adaptabletools.com/docs/reference/adaptableobject.md) | Actual Adaptable Object being shared |
| [EntityDependencyIds](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#entitydependencyids) | `TypeUuid[]` | Ids of direct entity dependencies |
| [EntityType](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#entitytype) | `'adaptableEntity'` | Type of shared entity (either Adaptable specific or custom object) |
| [LayoutExtensions](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#layoutextensions) | [`LayoutExtensionInfo`](https://www.adaptabletools.com/docs/reference/layoutextensioninfo.md) | Shared Layouts only: names of the objects, per Module, extended into the Layout when it was shared;<br/>applied to the importing user&#39;s Layout Extensions so the Extended Layout arrives complete |
| [Module](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#module) | [`AdaptableModule`](https://www.adaptabletools.com/docs/reference/adaptablemodule.md) | Adaptable Module to which object belongs |
| [Revision](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#revision) | `number` | Revision - incremental for &#39;Active&#39;, always 1 for &#39;Snapshot&#39; |
| [SharedAtMajorVersion](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#sharedatmajorversion) | `number` | Major AdapTable version this entity was last shared or migrated with.<br/>When it matches the running major, the upgrade chain is skipped. |
| [Timestamp](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#timestamp) | `number` | When the object was shared |
| [Type](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#type) | [`SharedEntityType`](https://www.adaptabletools.com/docs/reference/sharedentitytype.md) | &#39;Snapshot&#39; (for 1-time sharing) or &#39;Active&#39; (for continuous sharing) |
| [UserName](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#username) | `string` | User who shared the object |
| [IsReadOnly](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md#isreadonly) | `boolean` | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of &#39;Full&#39;) |

`Type` is a [`SharedEntityType`](https://www.adaptabletools.com/docs/reference/sharedentitytype.md):

[See API: sharedentitytype](https://www.adaptabletools.com/docs/reference/sharedentitytype.md)

`Module` is an [`AdaptableModule`](https://www.adaptabletools.com/docs/reference/adaptablemodule.md):

[See API: adaptablemodule](https://www.adaptabletools.com/docs/reference/adaptablemodule.md)

`LayoutExtensions` is a [`LayoutExtension`](https://www.adaptabletools.com/docs/reference/layoutextension.md) without `LayoutName`. The properties are on the [Layout](https://www.adaptabletools.com/docs/technical-reference-layouts/index.md#layout-extensions) technical reference.

### Event Subscription

Subscribing to the Event is done the same way as with all [Adaptable Events](https://www.adaptabletools.com/docs/technical-reference-adaptable-events/index.md):

```ts
api.eventApi.on('TeamSharingEntityChanged', (eventInfo: TeamSharingEntityChangedInfo) => {
    // do something with the info
});
```
<hr/>

## Team Sharing Options

| Property | Type | Description | Default |
| --- | --- | --- | --- |
| [applySharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#applysharedentities) | `(sharedEntities: `[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[], context: `[`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md)`) => `[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]` | Allows hooking into Shared Entities loading process |   |
| [enableTeamSharing](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#enableteamsharing) | `boolean` | Whether Team Sharing is enabled | false |
| [handleCustomSharedEntityImport](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#handlecustomsharedentityimport) | `(sharedEntity: `[`CustomSharedEntity`](https://www.adaptabletools.com/docs/reference/customsharedentity.md)`, context: `[`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md)`) => void` | Handles import of Custom Shared Entities |   |
| [loadSharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#loadsharedentities) | `(context: `[`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md)`) => Promise<`[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]>` | (Async) Loads available Shared Entities - user can download and auto-merge with Adaptable State | null |
| [persistMigratedSharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#persistmigratedsharedentities) | `boolean` | When `true` (the default), a user with full Team Sharing rights writes shared<br/>entities back once per grid session after they are migrated on load, so the<br/>server copy matches the current shape. That write does not change `Revision`<br/>or `ChangedAt`.<br/><br/>Set to `false` when the server is read-only for most users. | true |
| [persistSharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#persistsharedentities) | `(sharedEntities: `[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[], context: `[`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md)`) => Promise<void>` | (Async) Persists Shared Entities so that they can be downloaded by other team members | null |
| [saveSharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#savesharedentities) | `(sharedEntities: `[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[], context: `[`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md)`) => `[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]` | Allows hooking into Shared Entities persistence process |   |
| [showUpdateNotificationOncePerUpdate](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#showupdatenotificationonceperupdate) | `boolean` | Whether to show update notification once per update | false |
| [suppressOverrideConfigWarning](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#suppressoverrideconfigwarning) | `boolean` | Suppress warning when an Import overrides existing Adaptable State item | false |
| [updateInterval](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#updateinterval) | `number` | Frequency (in minutes) to check if Active Shared Entities have a newer revision | 0 (never) |
| [updateNotification](https://www.adaptabletools.com/docs/reference/teamsharingoptions.md#updatenotification) | `'Alert' \| 'AlertWithNotification' \| 'SystemStatus'` | How user is informed when Active Shared Entities have newer revisions | null (none) |

`applySharedEntities` receives a [`SharedEntitiesContext`](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md):

| Property | Type | Description |
| --- | --- | --- |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/sharedentitiescontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

`handleCustomSharedEntityImport` receives a [`CustomSharedEntity`](https://www.adaptabletools.com/docs/reference/customsharedentity.md):

| Property | Type | Description |
| --- | --- | --- |
| [ChangedAt](https://www.adaptabletools.com/docs/reference/customsharedentity.md#changedat) | `number` | Last time when the object was changed |
| [ChangedBy](https://www.adaptabletools.com/docs/reference/customsharedentity.md#changedby) | `string` | Last User who changed the object |
| [Description](https://www.adaptabletools.com/docs/reference/customsharedentity.md#description) | `string` | Description of object being shared |
| [Entity](https://www.adaptabletools.com/docs/reference/customsharedentity.md#entity) | `T` | Custom Object being shared |
| [EntityType](https://www.adaptabletools.com/docs/reference/customsharedentity.md#entitytype) | `'customEntity'` | Type of shared entity (either Adaptable specific or custom object) |
| [IsReadOnly](https://www.adaptabletools.com/docs/reference/customsharedentity.md#isreadonly) | `boolean` | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of &#39;Full&#39;) |
| [Name](https://www.adaptabletools.com/docs/reference/customsharedentity.md#name) | `string` | Name of object being shared |
| [Tags](https://www.adaptabletools.com/docs/reference/customsharedentity.md#tags) | [`AdaptableObjectTag`](https://www.adaptabletools.com/docs/reference/adaptableobjecttag.md)`[]` | List of Tags associated with the Object |
| [Timestamp](https://www.adaptabletools.com/docs/reference/customsharedentity.md#timestamp) | `number` | When the object was shared |
| [UserName](https://www.adaptabletools.com/docs/reference/customsharedentity.md#username) | `string` | User who shared the object |
| [Uuid](https://www.adaptabletools.com/docs/reference/customsharedentity.md#uuid) | `TypeUuid` | Unique identifier for the Custom Shared Entity |

## Team Sharing State

[`TeamSharingState`](https://www.adaptabletools.com/docs/reference/teamsharingstate.md) is run-time state. It is not supplied in Initial Adaptable State.

| Property | Type | Description |
| --- | --- | --- |
| [ActiveSharedEntityMap](https://www.adaptabletools.com/docs/reference/teamsharingstate.md#activesharedentitymap) | `Record<TypeUuid, `[`AdaptableSharedEntity`](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md)`>` | Mapping of active AdaptableObjects which are shared with the local state.<br/>Maps UUIDs of local AdaptableObjects to a snapshot of the latest synchronized SharedEntity |
| [importProcessInProgress](https://www.adaptabletools.com/docs/reference/teamsharingstate.md#importprocessinprogress) | `boolean` | TRUE if an import is in progress, FALSE otherwise.<br/>This is required to skip the TEAMSHARING_UPDATE_ITEM action as a result of the import |
| [SharedEntities](https://www.adaptabletools.com/docs/reference/teamsharingstate.md#sharedentities) | [`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]` | List of objects currently being Team Shared |

## Team Sharing API

| Method | Returns | Description |
| --- | --- | --- |
| [checkForUpdates()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#checkforupdates) | `void` | Checks if active Shared Entities have updates (higher revisions than the local counterpart objects) |
| [getLoadedAdaptableSharedEntities()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#getloadedadaptablesharedentities) | [`AdaptableSharedEntity`](https://www.adaptabletools.com/docs/reference/adaptablesharedentity.md)`[]` | Retrieves locally loaded Adaptable Shared Entries. |
| [getLoadedCustomSharedEntities()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#getloadedcustomsharedentities) | [`CustomSharedEntity`](https://www.adaptabletools.com/docs/reference/customsharedentity.md)`[]` | Retrieves locally loaded Custom Shared Entries. |
| [getLoadedSharedEntities()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#getloadedsharedentities) | [`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]` | Retrieves all locally loaded shared entries (`AdaptableSharedEntity` &amp; `CustomSharedEntity`). |
| [hasTeamSharingFullRights()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#hasteamsharingfullrights) | `boolean` | Whether current user has full Team Sharing rights (for creating &amp; updating shared items) |
| [importSharedEntry(sharedEntity)](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#importsharedentry) | `void` | Import the given Shared Entity. In case of `CustomSharedEntity`, the import logic will be delegated to `TeamSharingOptions.handleCustomSharedEntityImport(...)`. |
| [isTeamSharingAvailable()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#isteamsharingavailable) | `boolean` | Whether Team Sharing is available to use |
| [loadSharedEntities()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#loadsharedentities) | `Promise<`[`SharedEntity`](https://www.adaptabletools.com/docs/reference/sharedentity.md)`[]>` | Retrieves all currently shared entities; async operation leveraging `TeamSharingOptions.loadSharedEntities(...)` method |
| [openTeamSharingSettingsPanel()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#openteamsharingsettingspanel) | `void` | Opens Settings Panel with Team Sharing section selected and visible |
| [persistSharedEntities(sharedEntities)](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#persistsharedentities) | `Promise<boolean>` | Sets currently shared entities; async operation leveraging `TeamSharingOptions.persistSharedEntities(...)` method |
| [refreshTeamSharing()](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#refreshteamsharing) | `void` | Refreshes the local TeamSharing state by (re)loading the remote state. |
| [shareAdaptableEntity(adaptableObject, module, sharedEntityConfig)](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#shareadaptableentity) | `void` | Puts an Adaptable Object into Team Share |
| [shareCustomEntity(customObject, sharedEntityConfig)](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#sharecustomentity) | `void` | Puts an custom Object into Team Share |
| [unshareEntity(entityId)](https://www.adaptabletools.com/docs/reference/teamsharingapi.md#unshareentity) | `void` | Removes a Shared Entity from the Team Share. |
