Changing Versions with the VersionManagementService

Note: Sign in to access the data in this sample. username: viewer01 password: I68VGU^nMurF

This sample demonstrates how to utilize the VersionManagementService to change versions on a FeatureLayer.

Getting started

To use this sample, select a version from the list menu. Once you have selected a version, you will notice that the features will update to based on the selected version.

change-version-ui.png

The code below demonstrates how to retrieve a list of versions from the current Version Management Service.

Use dark colors for code blocksCopy
1
2
3
4
5
const currentVMS = new VersionManagementService({
  url: "https://sampleserver7.arcgisonline.com/server/rest/services/US_Cities_Branch/VersionManagementServer"
});
await currentVMS.load();
versions = await currentVMS.getVersionInfos();

This code demonstrates that after instantiating an instance of the VersionManagementService class, we load the instance. By calling getVersionInfos(), a list of versions can be retrieved.

The code below changes a version by accepting the featureLayerList, currentVersion, and the newVersion.

Use dark colors for code blocksCopy
1
2
3
4
async function changeVersion(featureLayerList, newVersion, currentVersion) {
  await currentVMS.changeVersion(featureLayerList, currentVersion, newVersion);
  currentVersionIdentifier = newVersion;
}

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