import VersionManagementViewModel from "@arcgis/core/widgets/VersionManagement/VersionManagementViewModel.js";const VersionManagementViewModel = await $arcgis.import("@arcgis/core/widgets/VersionManagement/VersionManagementViewModel.js");- Inheritance:
- VersionManagementViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.29
This class allows you to manage versions from a variety of feature services.
The VersionManagementViewModel allows you to alter, create, delete versions etc. provided that a featureServiceUrl is provided for these operations.
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 viewModel = new VersionManagementViewModel({ view });await whenOnce(() => viewModel.state === "ready");Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
executionError readonly | | |
| | ||
loadError readonly | | |
| | ||
| | ||
state readonly | | |
| | ||
| | ||
| | ||
| | ||
| |
featureServiceLookup
A key-value pair of FeatureServiceResourcesBundle.
serviceNameLookup
Map of Service URLs and service names. Keeps track of all the FeatureService instances in the VersionManagementService class instance.
versioningStateLookup
- Type
- Map<string, VersioningState>
This property contains metadata about the versioning state.
versioningStates
- Type
- Collection<VersioningState>
Methods
| Method | Signature | Class |
|---|---|---|
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
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameters | Parameters used to alter a version. | |
Example
await versionManagementViewModel.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
- 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
- Returns
- Promise<Map<VersionAdapter, ServiceResult>>
When resolved, returns a map of version adapter to result.
Example
await versionManagementViewModel.changeVersion( "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0", "incomingVersionName", "incomingVersionGuid" ) createVersion
- Signature
-
createVersion (parameters: CreateVersionParameters): Promise<VersionInfoExtendedJSON>
Creates a new version given the following parameters.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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 viewModel.createVersion({ featureServerUrl: "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0", versionName: "NewVersionName", description: "New Version Description", access: "public",}); deleteVersion
- 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
Example
await versionManagementViewModel.deleteVersion( "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0", "versionName", "{45A4CF5B-69FB-4D94-96F7-25F92EB4C0EC}"); getVersionInfos
- Signature
-
getVersionInfos (featureServerUrl: string): Promise<VersionInfo[]>
Returns all versions accessible to the currently logged-in user.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| featureServerUrl | The url of a feature service. | |
- Returns
- Promise<VersionInfo[]>
When resolved, returns an array of
VersionInfo.
Example
const versionInfos = await versionManagementViewModel.getVersionInfos("https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0");Type definitions
VersionManagementViewModelExecutionError
- Type
- "no-feature-service-found" | "no-valid-enterprise-version" | "no-valid-version-name" | "no-version-management-service-found" | undefined
VersionManagementViewModelLoadError
- Type
- "no-feature-services" | "no-layers-property" | undefined