VersionManagementViewModel

AMD: require(["esri/widgets/VersionManagement/VersionManagementViewModel"], (VersionManagementViewModel) => { /* code goes here */ });
ESM: import VersionManagementViewModel from "@arcgis/core/widgets/VersionManagement/VersionManagementViewModel.js";
Class: esri/widgets/VersionManagement/VersionManagementViewModel
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.

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 viewModel = new VersionManagementViewModel({ view });
await whenOnce(() => viewModel.state === "ready");

Constructors

VersionManagementViewModel

Constructor
new VersionManagementViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Map<string, boolean>

Map of Service URLs and user type extensions.

VersionManagementViewModel
String

The name of the class.

Accessor
String

Displays execution errors.

VersionManagementViewModel
Map<string, FeatureServiceResourcesBundle>

A key-value pair of FeatureServiceResourcesBundle.

VersionManagementViewModel
String

Displays an error if loading fails.

VersionManagementViewModel
Map<string, number>

Map of Service URLs and enterprise versions.

serverVersionLookup
Map<string, string>

Map of Service URLs and service names.

VersionManagementViewModel
String

The viewModel's state.

VersionManagementViewModel
Map<string, string>

Map of Service URLs and logged in users .

VersionManagementViewModel
Map<string, VersionIdentifier>

A Map of current version identifiers keyed on the map service url.

VersionManagementViewModel
Map<string, VersionInfo[]>

Contains information about the versions in the versionmanagementservice such as name, guid, etc

VersionManagementViewModel
Map<string, VersionManagementService>

This class contains metadata about the version management service.

VersionManagementViewModel
MapView

The view from which the widget will operate.

VersionManagementViewModel

Property Details

advancedEditingUserTypeExtensionLookup

Property
advancedEditingUserTypeExtensionLookup Map<string, boolean>readonly

Map of Service URLs and user type extensions.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

executionError

Property
executionError Stringreadonly

Displays execution errors.

featureServiceLookup

Property
featureServiceLookup Map<string, FeatureServiceResourcesBundle>

A key-value pair of FeatureServiceResourcesBundle.

loadError

Property
loadError Stringreadonly

Displays an error if loading fails.

serverVersionLookup

Property
serverVersionLookup Map<string, number>inner,readonly

Map of Service URLs and enterprise versions.

serviceNameLookup

Property
serviceNameLookup Map<string, string>

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

state

Property
state Stringreadonly

The viewModel's state.

Possible Values:"disabled"|"executing"|"failed"|"loading"|"ready"

userLookup

Property
userLookup Map<string, string>readonly

Map of Service URLs and logged in users .

versionIdentifierLookup

Property
versionIdentifierLookup Map<string, VersionIdentifier>readonly

A Map of current version identifiers keyed on the map service url.

versionInfoLookup

Property
versionInfoLookup Map<string, VersionInfo[]>

Contains information about the versions in the versionmanagementservice such as name, guid, etc

versionManagementServiceLookup

Property
versionManagementServiceLookup Map<string, VersionManagementService>

This class contains metadata about the version management service.

view

Property
view MapView

The view from which the widget will operate.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor
Promise<void>

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

VersionManagementViewModel
Promise<void>

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

VersionManagementViewModel
Promise<void>

Creates a new version given the following parameters.

VersionManagementViewModel
Promise<void>

Deletes a version given the following parameters.

VersionManagementViewModel
Boolean

Emits an event on the instance.

VersionManagementViewModel
Promise<VersionInfo[]>

Returns an array of versions.

VersionManagementViewModel
Boolean

Indicates whether there is an event listener on the instance that matches the provided event name.

VersionManagementViewModel
Boolean

Returns true if a named group of handles exist.

Accessor
Object

Registers an event handler on the instance.

VersionManagementViewModel

Removes a group of handles owned by the object.

Accessor

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

alterVersion

Method
alterVersion(parameters){Promise<void>}

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

License

Parameter

Parameters used to alter a version.

Returns
Type Description
Promise<void>
  • Resolves when the alter operation completes and the REST call returns a response.
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

Method
changeVersion(featureServerUrl, toVersionName, toVersionGuid){Promise<void>}

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

Parameters
featureServerUrl String

The url of a feature service.

toVersionName String

Incoming version name.

toVersionGuid String

Incoming version guid.

Returns
Type Description
Promise<void>
  • Resolves when the target has switched to the incoming version.
Example
await versionManagementViewModel.changeVersion(
  "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
  "incomingVersionName",
  "incomingVersionGuid"
 )

createVersion

Method
createVersion(parameters){Promise<void>}

Creates a new version given the following parameters.

Parameter

Parameters used to create a new version.

Returns
Type Description
Promise<void>
  • Resolves when the create operation completes and the REST call returns a response.
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

Method
deleteVersion(featureServerUrl, versionName, versionGuid){Promise<void>}

Deletes a version given the following parameters.

License

Parameters
featureServerUrl String

The url of a feature service.

versionName String

The name of the version that is to be deleted.

versionGuid String

The guid of the version that is to be deleted.

Returns
Type Description
Promise<void>
  • Resolves when the delete operation completes and the REST call returns a response.
Example
await versionManagementViewModel.deleteVersion(
   "https://myHostName.domain.com/arcgis/rest/services/TestService_11_2/FeatureServer/0",
   "versionName",
   "{45A4CF5B-69FB-4D94-96F7-25F92EB4C0EC}"
 );

emit

Method
emit(type, event){Boolean}

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
type String

The name of the event.

event Object
optional

The event payload.

Returns
Type Description
Boolean true if a listener was notified

getVersionInfos

Method
getVersionInfos(featureServerUrl, refreshVersionInfos){Promise<VersionInfo[]>}

Returns an array of versions.

Parameters
featureServerUrl String

The url of a feature service.

refreshVersionInfos Boolean

If true, the API sends a new request to the REST endpoint, and if false, the API returns results from a cache (a new request is sent if it's the first time you call getVersionInfos).

Returns
Type Description
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", true);

hasEventListener

Method
hasEventListener(type){Boolean}

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameter
type String

The name of the event.

Returns
Type Description
Boolean Returns true if the class supports the input event.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

on

Method
on(type, listener){Object}

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters

An event or an array of events to listen for.

listener Function

The function to call when the event fires.

Returns
Type Description
Object Returns an event handler with a remove() method that should be called to stop listening for the event(s).
Property Type Description
remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){
  // event is the event handle returned after the event fires.
  console.log(event.mapPoint);
});

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Type Definitions

AlterVersionParameters

Type Definition
AlterVersionParameters Object

Parameters used to alter a version.

Properties
featureServerUrl String

The url of a feature service.

versionIdentifier VersionIdentifier

The Identifier of a version.

ownerName String
optional

The new owner name of the version.

versionName String
optional

The new name for the version.

access String
optional

The new access permissions of the version.

Possible Values:"hidden"|"private"|"protected"|"public"

description String
optional

The new description for the version.

CreateVersionParameters

Type Definition
CreateVersionParameters Object

Parameters used to create a new version.

Properties
featureServerUrl String

The url of a feature service.

versionName String

The name of the new version.

access String

The access type of the new version.

Possible Values:"hidden"|"private"|"protected"|"public"

description String
optional

The description of the new version.

ownerName String
optional

The version owner.

FeatureServiceResourcesBundle

Type Definition
FeatureServiceResourcesBundle Object

Contains FeatureService and array of Layer.

Properties
featureService FeatureService

The feature service.

layers Layer[]

An array of layers from the feature service.

VersionInfo

Type Definition
VersionInfo Object

Contains info about a Version.

Properties
versionIdentifier VersionIdentifier

The Identifier of a version.

description String
optional

Description of the version.

access String
optional

The access type permissions of the version.

Possible Values:"hidden"|"private"|"protected"|"public"

versionId String
optional

The id of the version that was edited.

creationDate Number
optional

The date the version was created on.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.