VersionManagementService

AMD: require(["esri/versionManagement/VersionManagementService"], (VersionManagementService) => { /* code goes here */ });
ESM: import VersionManagementService from "@arcgis/core/versionManagement/VersionManagementService.js";
Class: esri/versionManagement/VersionManagementService
Since: ArcGIS Maps SDK for JavaScript 4.28

This class contains metadata about the version management service. The class can be constructed via a url to a version management service. The VersionManagementService grants users to plethora of functionality. The VersionManagementService contains methods for creating a new version, deleting a version, altering a version, changing a version on layers, start/stop reading, start/stop editing, reconciling, posting, and getting version infos. The Version Management Component offers another way to handle versioning using a UI.

See also
Example
// Initialize the VersionManagementService from a url
const versionManagementService = new VersionManagementService({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
});

// The layers that will be managed under the VersionManagementService
const layer1 = await new FeatureLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/12"
});
const layer2 = await new FeatureLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/13"
});
const layers = [layer1, layer2];

// The VersionManagementService must be loaded before any methods can be called
await versionManagementService.load();

// Change the version of two layers
versionManagementService.changeVersion(
  layers,
  { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"},
  { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
);

Constructors

VersionManagementService

Constructor
new VersionManagementService(properties)
Parameter
properties Object
optional

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

Example
// Create a Version Management Service from a url
const versionManagementService = new VersionManagementService({
 url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
});

Property Overview

Name Type Summary Class
VersionManagementServiceCapabilities

Describes the version management service's supported capabilities.

VersionManagementService
VersionIdentifier

Contains the value for the default version's name and GUID.

VersionManagementService
Boolean

Indicates whether the instance has loaded.

VersionManagementService
Error

The Error object returned if an error occurred while loading.

VersionManagementService
String

Represents the status of a load operation.

VersionManagementService
String

The name of the version management service.

VersionManagementService
String

The absolute URL of the REST endpoint for the version management service.

VersionManagementService

Property Details

capabilities

Property
capabilities VersionManagementServiceCapabilities

Describes the version management service's supported capabilities.

defaultVersionIdentifier

Property
defaultVersionIdentifier VersionIdentifier

Contains the value for the default version's name and GUID.

loaded

Property
loaded Booleanreadonly

Indicates whether the instance has loaded. When true, the properties of the object can be accessed. A WebMap is considered loaded when its layers and basemap are created, but not yet loaded.

Default Value:false

loadError

Property
loadError Errorreadonly

The Error object returned if an error occurred while loading.

Default Value:null

loadStatus

Property
loadStatus Stringreadonly

Represents the status of a load operation.

Value Description
not-loaded The object's resources have not loaded.
loading The object's resources are currently loading.
loaded The object's resources have loaded without errors.
failed The object's resources failed to load. See loadError for more details.

Possible Values:"not-loaded"|"loading"|"failed"|"loaded"

Default Value:not-loaded

name

Property
name String

The name of the version management service.

url

Property
url String

The absolute URL of the REST endpoint for the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.

Method Overview

Name Return Type Summary Class
Promise<boolean>

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

VersionManagementService
Boolean

canRedo may be used to verify that a redo operation is possible.

VersionManagementService
Boolean

canUndo may be used to verify that an undo operation is possible.

VersionManagementService
Promise<boolean>

Method used to change a layer's version/moment or network's version/moment.

VersionManagementService
Promise<VersionInfoExtendedJSON>

Creates a new version given the following parameters.

VersionManagementService
Promise<boolean>

Deletes a version given the following parameters.

VersionManagementService
String

Returns the current client lock type on a given version.

VersionManagementService
VersionIdentifier

This method will return the versionIdentifier given the guid of the version.

VersionManagementService
VersionIdentifier

This method will return the versionIdentifier given the name of the version.

VersionManagementService
Promise<VersionInfoExtendedJSON>

Method used to get extended information about a version.

VersionManagementService
Promise<VersionInfoJSON[]>

Returns information about a version or versions.

VersionManagementService
Promise

Triggers the loading of the version management service instance.

VersionManagementService
Promise<PostResult>

The Post operation allows the client to post the changes in their version to the default version.

VersionManagementService
Promise<ReconcileResult>

Use the reconcile operation to reconcile a branch version with the default version.

VersionManagementService

This method redos the last edit made while in an edit session.

VersionManagementService
Promise<boolean>

Using the specified session ID an exclusive lock is obtained for the session on the version.

VersionManagementService
Promise<boolean>

Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.

VersionManagementService
Promise<boolean>

Using the specified session id, the exclusive lock for the version is downgraded to a shared lock.

VersionManagementService
Promise<boolean>

The shared lock is released on the version.

VersionManagementService

This method undos the last edit made while in an edit session.

VersionManagementService

Method Details

alterVersion

Method
alterVersion(versionIdentifier, props){Promise<boolean>}

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

License

Parameters
Specification
versionIdentifier VersionIdentifier

Identifier for a version.

props Object

Contains properties that will be altered.

Specification
ownerName String
optional

The new owner name of the version.

versionName String
optional

The new name for the version.

description String
optional

The new description for the version.

access String
optional

The new access permissions of the version.

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

Returns
Type Description
Promise<boolean>
  • Returns true if version was altered successfully.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

const result = await versionManagementService.alterVersion(
  { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" },
    {
      versionName: "versionName",
      ownerName: "newOwner",
      description: "newDescription",
      access: "public"
    }
 );

canRedo

Method
canRedo(versionIdentifier){Boolean}

canRedo may be used to verify that a redo operation is possible.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Boolean
  • Indicates whether a redo operation is possible.

canUndo

Method
canUndo(versionIdentifier){Boolean}

canUndo may be used to verify that an undo operation is possible.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Boolean
  • Indicates whether an undo operation is possible.

changeVersion

Method
changeVersion(input, fromVersion, toVersion){Promise<boolean>}

Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version, or from default version to a moment and vice versa.

Parameters

Input used to change version on layers or network.

fromVersion Date|VersionIdentifier

Current Version or Date moment.

Incoming Version or Date.

Returns
Type Description
Promise<boolean>
  • When resolved, response is true if change version was successful.
Example
// Initialize the VersionManagementService from a url
const versionManagementService = new VersionManagementService({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"
});

const layer1 = await new FeatureLayer({
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/12"
    });
const layer2 = await new FeatureLayer({
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/13"
    });
const layers = [layer1, layer2];

// Make sure the VersionManagementService is loaded
await versionManagementService.load();

await versionManagementService.changeVersion(
    layers,
    { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"},
    { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
 );

createVersion

Method
createVersion(props){Promise<VersionInfoExtendedJSON>}

Creates a new version given the following parameters.

Parameters
Specification
props Object
optional

Contains properties required to create a version.

Specification
versionName String

The name of the new version.

description String
optional

The description of the new version.

access String
optional

The access type of the new version.

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

Returns
Type Description
Promise<VersionInfoExtendedJSON>
  • Contains information about newly created version.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

// Create a version by passing the new version name, description, and access type set to 'public'.
const version = await versionManagementService.createVersion({
  versionName: "versionName",
  description: "description",
  access: "public"
});

deleteVersion

Method
deleteVersion(versionIdentifier){Promise<boolean>}

Deletes a version given the following parameters.

License

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<boolean>
  • Specifies if the selected version was deleted.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

versionManagementService.deleteVersion({
  name: "versionName",
  guid: "{422D1B63-D795-4478-A4B1-AD6109377075}"
});

getLockType

Method
getLockType(versionIdentifier){String}

Returns the current client lock type on a given version.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
String
  • Specifies the lock type on the version. Returns either "edit", "none", or "read".
Example
versionManagementService.getLockType({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });

getVersionIdentifierFromGuid

Method
getVersionIdentifierFromGuid(guid){VersionIdentifier}

This method will return the versionIdentifier given the guid of the version.

Parameter
guid String

GUID of version.

Returns
Type Description
VersionIdentifier
  • Returns VersionIdentifier.

getVersionIdentifierFromName

Method
getVersionIdentifierFromName(name){VersionIdentifier}

This method will return the versionIdentifier given the name of the version.

Parameter
name String

Name of version.

Returns
Type Description
VersionIdentifier
  • Returns VersionIdentifier.

getVersionInfoExtended

Method
getVersionInfoExtended(versionIdentifier){Promise<VersionInfoExtendedJSON>}

Method used to get extended information about a version.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<VersionInfoExtendedJSON>
  • Contains extended info about given version.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

const version = await versionManagementService.getVersionInfoExtended({
  guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
  name: "versionName"
});

getVersionInfos

Method
getVersionInfos(props){Promise<VersionInfoJSON[]>}

Returns information about a version or versions. If no parameters are passed, all versions will be returned.

Parameters
Specification
props Object
optional
Specification
ownerFilter String

Filter to query versions by owner name.

includeHidden Boolean

Specifies whether to include hidden versions. This is false by default.

Returns
Type Description
Promise<VersionInfoJSON[]>
  • Contains info of versions.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

const versions = await versionManagementService.getVersionInfos({ ownerFilter: "publisher1", includeHidden: true });

load

Method
load(){Promise}

Triggers the loading of the version management service instance.

Fully loads the Version Management Service definition.

Returns
Type Description
Promise Resolves when the Feature Service is loaded.

post

Method
post(versionIdentifier){Promise<PostResult>}

The Post operation allows the client to post the changes in their version to the default version. A reconcile operation must be performed prior to post.

License

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<PostResult>
  • Returns the result of the post.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

const postResult = await versionManagementService.post({
  guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
  name: "versionName"
});

reconcile

Method
reconcile(versionIdentifier, props){Promise<ReconcileResult>}

Use the reconcile operation to reconcile a branch version with the default version. The reconcile operation requires that you are the only user currently editing the version and remain so throughout the reconcile process until you save or post your edits. You must have full permissions to all the feature classes that have been modified in the version being edited. This operation detects differences between the branch version and the default version and flags these differences as conflicts.

License

Parameters
Specification
versionIdentifier VersionIdentifier

Identifier for a version.

props Object

Properties used for a reconcile.

Specification
abortIfConflicts Boolean

Specifies whether the reconcile should be aborted if conflicts are found. The default is false

conflictDetection String

Specifies the conditions required for conflicts to occur are defined by object (row) or attribute (column).

Possible Values:"by-attribute"|"by-object"

withPost Boolean

Specifies if post will occur after calling reconcile. Causes post to occur immediately after reconcile, fales by default.

Returns
Type Description
Promise<ReconcileResult>
  • Returns the result of the reconcile.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

const reconcileResult = await versionManagementService.reconcile({
   guid: "{422D1B63-D795-4478-A4B1-AD6109377075}",
   name: "versionName"
  },
  {
    abortIfConflicts: true,
    conflictDetection: "by-object",
    withPost: false
});

redo

Method
redo(versionIdentifier)

This method redos the last edit made while in an edit session.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

startEditing

Method
startEditing(versionIdentifier){Promise<boolean>}

Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock. The exclusive lock ensures read and write isolation for the session holding the lock. The exclusive lock is downgraded to a shared lock by using the stopEditing operation.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<boolean>
  • Specifies if start editing was successful.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

versionManagementService.startEditing({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });

startReading

Method
startReading(versionIdentifier){Promise<boolean>}

Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<boolean>
  • Specifies if start reading was successful.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

versionManagementService.startReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });

stopEditing

Method
stopEditing(versionIdentifier, saveEdits){Promise<boolean>}

Using the specified session id, the exclusive lock for the version is downgraded to a shared lock. The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).

Parameters
versionIdentifier VersionIdentifier

Identifier for a version.

saveEdits Boolean

If set to true edits will be saved, if false edits will not be saved.

Returns
Type Description
Promise<boolean>
  • Specifies if stop editing was successful.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

versionManagementService.stopEditing({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}", saveEdits: true });

stopReading

Method
stopReading(versionIdentifier){Promise<boolean>}

The shared lock is released on the version.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Returns
Type Description
Promise<boolean>
  • Specifies if stop reading was successful.
Example
// Make sure the VersionManagementService is loaded
await versionManagementService.load();

versionManagementService.stopReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" });

undo

Method
undo(versionIdentifier)

This method undos the last edit made while in an edit session.

Parameter
versionIdentifier VersionIdentifier

Identifier for a version.

Type Definitions

PostResult

Type Definition
PostResult Object

This contains information about the post result.

Properties
moment Date

Returns data moments of the post.

success Boolean

Specifies if the post rest call was successful.

ReconcileResult

Type Definition
ReconcileResult Object

This contains information about the reconcile result.

Properties
hasConflicts Boolean

Specifies if the reconcile returned with conflicts.

moment Date

Returns data moment of the reconcile.

didPost Boolean

Specifies if the updates from the version were posted.

success Boolean

Specifies if the reconcile rest call was successful.

VersionIdentifier

Type Definition
VersionIdentifier Object

Holds the name and guid of a version.

Properties
name String

The version name.

guid String

The version GUID.

VersionInfoExtendedJSON

Type Definition
VersionInfoExtendedJSON Object

This contains extended information about a given version.

Properties
versionIdentifier Object

The identifier of a version.

Specification
name String

The name of the version.

guid String

The guid 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.

modifiedDate Number
optional

The date when the version was last modified or changed.

reconcileDate Number
optional

The date when the version was last reconciled with the parent version or the default version.

evaluationDate Number
optional

The date when the version was last evaluated for conflicts or discrepancies during the reconciliation process.

previousAncestorDate Number
optional

The date of the most recent ancestor version, if applicable.

commonAncestorDate Number
optional

The date of the common ancestor version, which is the shared ancestor between two or more versions during the reconciliation process.

isBeingEdited Boolean
optional

Specifies if the version is currently being edited.

isBeingRead Boolean
optional

Specifies if the version is currently being read.

hasConflicts Boolean
optional

Specifies if the version is has conflicts.

hasUninspectedConflicts Boolean
optional

Specifies if the version has UninspectedConflicts.

isLocked Boolean
optional

Specifies if the version currenlty has a lock.

lockOwner String
optional

Specifies which user is the current lock owner.

lockDate Number
optional

Specifies the date at which the version was locked.

VersionInfoJSON

Type Definition
VersionInfoJSON Object

This contains basic information about a given version.

Properties
versionIdentifier Object

The identifier of a version.

Specification
name String

The name of the version.

guid String

The guid of a version.

description String
optional

Description of the version.

access String
optional

Access type accepts values of private, public, hidden, and protected.

versionId String
optional

The id of the version that was edited.

creationDate Number
optional

The date the version was created on.

modifiedDate Number
optional

The date when the version was last modified or changed.

reconcileDate Number
optional

The date when the version was last reconciled with the parent version or the default version.

evaluationDate Number
optional

The date when the version was last evaluated for conflicts or discrepancies during the reconciliation process.

previousAncestorDate Number
optional

The date of the most recent ancestor version, if applicable.

commonAncestorDate Number
optional

The date of the common ancestor version, which is the shared ancestor between two or more versions during the reconciliation process.

VersionManagementServiceCapabilities

Type Definition
VersionManagementServiceCapabilities Object

Describes the version management service's supported capabilities.

Properties
supportsConflictDetectionByAttribute Boolean

Indicates whether the service supports conflict detection based on attribute values during editing operations.

supportsPartialPost Boolean

Indicates whether the service supports partial posting, allowing users to post only a subset of edits instead of the entire set.

supportsDifferencesFromMoment Boolean

Indicates whether the service supports retrieving differences in data from a specific moment in time.

supportsDifferencesWithLayers Boolean

Indicates whether the service supports retrieving differences in data between different layers or feature classes.

supportsAsyncReconcile Boolean

Indicates whether the service supports asynchronous reconcile operations, allowing users to reconcile conflicting edits asynchronously.

supportsAsyncPost Boolean

Indicates whether the service supports asynchronous posting of edits, allowing users to post edits asynchronously.

supportsAsyncDifferences Boolean

Indicates whether the service supports asynchronous retrieval of differences in data, allowing users to retrieve differences asynchronously.

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