Note: Sign in to access the data in this sample. username
password
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.
The code below demonstrates how to retrieve a list of versions from the current Version Management Service.
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.
async function changeVersion(featureLayerList, newVersion, currentVersion) {
await currentVMS.changeVersion(featureLayerList, currentVersion, newVersion);
currentVersionIdentifier = newVersion;
}