Skip to content
import VersionManager from "@arcgis/core/versionManagement/VersionManager.js";
Inheritance:
VersionManagerAccessor
Since
ArcGIS Maps SDK for JavaScript 5.0

This class allows you to manage versions from a variety of feature services. The VersionManager allows you to alter, create, delete versions etc. provided that a featureServiceUrl is provided for these operations.

See also
Example
const webMap = new WebMap({
portalItem: {
id: "webmapID"
}
});
const view = new MapView({
map: webMap
});
featureLayer = new FeatureLayer({
url: "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
});
webMap.layers.add(featureLayer);
const versionManager = new VersionManager({ view });
await whenOnce(() => versionManager.state === "ready");

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

executionError

readonly Property
Type
VersionManagerExecutionError | null | undefined

Displays execution errors.

featureServiceLookup

Property
Type
Map<string, FeatureServiceResourcesBundle>

A key-value pair of FeatureServiceResourcesBundle.

loadError

readonly Property
Type
VersionManagerLoadError | null | undefined

Displays an error if loading fails.

serverVersionLookup

Property
Type
Map<string, number>

Map of Service URLs and enterprise versions.

serviceNameLookup

Property
Type
Map<string, string>

Map of Service URLs and service names. Keeps track of all the FeatureService instances in the VersionManagementService class instance.

state

readonly Property
Type
VersionManagerState

The current state of this object.

userLookup

Property
Type
Map<string, string>

Map of Service URLs and logged in users .

versionAdministratorLookup

Property
Type
Map<string, boolean>

This property determines if a user has version admin privileges.

versioningStateLookup

Property
Type
Map<string, VersioningState>

This property contains metadata about the versioning state.

versioningStates

Property
Type
Collection<VersioningState>

view

Property
Type
MapView

This property defines the target MapView.

Methods

MethodSignatureClass
alterVersion(parameters: AlterVersionParameters): Promise<boolean>
changeVersion(featureServerUrl: string, toVersionName: string, toVersionGuid: string): Promise<Map<VersionAdapter, ServiceResult>>
createVersion(parameters: CreateVersionParameters): Promise<VersionInfoExtendedJSON>
deleteVersion(featureServerUrl: string, versionName: string, versionGuid: string): Promise<boolean>
getVersionInfos(featureServerUrl: string): Promise<VersionInfo[]>

alterVersion

Method
Signature
alterVersion (parameters: AlterVersionParameters): Promise<boolean>

The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions.

License

This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher.

Parameters
ParameterTypeDescriptionRequired
parameters

Parameters used to alter a version.

Returns
Promise<boolean>

When resolved, returns true if the alter operation completes successfully.

Example
await versionManager.alterVersion({
featureServiceUrl: "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
versionIdentifier: {
guid: myVersion.versionIdentifier.guid,
name: myVersion.versionIdentifier.name,
},
versionName: "updatedVersionName"
});

changeVersion

Method
Signature
changeVersion (featureServerUrl: string, toVersionName: string, toVersionGuid: string): Promise<Map<VersionAdapter, ServiceResult>>

Method used to change a version using a featureServerUrl, name, and guid of a version.

Parameters
ParameterTypeDescriptionRequired
featureServerUrl

The url of a feature service.

toVersionName

Incoming version name.

toVersionGuid

Incoming version guid.

Returns
Promise<Map<VersionAdapter, ServiceResult>>

When resolved, returns a map of version adapter to result.

Example
await versionManager.changeVersion(
"https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
"incomingVersionName",
"incomingVersionGuid"
)

createVersion

Method
Signature
createVersion (parameters: CreateVersionParameters): Promise<VersionInfoExtendedJSON>

Creates a new version given the following parameters.

Parameters
ParameterTypeDescriptionRequired
parameters

Parameters used to create a new version.

Returns
Promise<VersionInfoExtendedJSON>

When the promise is resolved, the VersionInfoExtendedJSON will be returned once the create operation is successfully completed.

Example
await versionManager.createVersion({
featureServerUrl: "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
versionName: "NewVersionName",
description: "New Version Description",
access: "public",
});

deleteVersion

Method
Signature
deleteVersion (featureServerUrl: string, versionName: string, versionGuid: string): Promise<boolean>

Deletes a version given the following parameters.

License

This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher.

Parameters
ParameterTypeDescriptionRequired
featureServerUrl

The url of a feature service.

versionName

The name of the version that is to be deleted.

versionGuid

The guid of the version that is to be deleted.

Returns
Promise<boolean>

When resolved, returns true if the delete operation completes successfully.

Example
await versionManager.deleteVersion(
"https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
"versionName",
"{45A4CF5B-69FB-4D94-96F7-25F92EB4C0EC}"
);

getVersionInfos

Method
Signature
getVersionInfos (featureServerUrl: string): Promise<VersionInfo[]>

Returns all versions accessible to the currently logged-in user.

Parameters
ParameterTypeDescriptionRequired
featureServerUrl

The url of a feature service.

Returns
Promise<VersionInfo[]>

When resolved, returns an array of VersionInfo.

Example
const versionInfos = await versionManager.getVersionInfos("https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0");

Type definitions

AlterVersionParameters

Type definition

Parameters used to alter a version.

featureServerUrl

Property
Type
string

The url of a feature service.

versionIdentifier

Property
Type
VersionIdentifier

The Identifier of a version.

ownerName

Property
Type
string | undefined

The new owner name of the version.

versionName

Property
Type
string | undefined

The new name for the version.

access

Property
Type
AccessType | undefined

The new access permissions of the version.

description

Property
Type
string | undefined

The new description for the version.

CreateVersionParameters

Type definition

Parameters used to create a new version.

featureServerUrl

Property
Type
string

The url of a feature service.

versionName

Property
Type
string

The name of the new version.

access

Property
Type
AccessType

The access type of the new version.

description

Property
Type
string

The description of the new version.

ownerName

Property
Type
string | undefined

The version owner.

VersionManagerExecutionError

Type definition
Type
"no-feature-service-found" | "no-valid-enterprise-version" | "no-valid-version-name" | "no-version-management-service-found" | undefined

VersionManagerLoadError

Type definition
Type
"no-feature-services" | "no-layers-property" | undefined

VersionManagerState

Type definition
Type
"loading" | "ready" | "executing" | "success" | "failed" | "disabled"