Edit with branch versioning

View inMAUIUWPWPFWinUIView on GitHub

Create, query and edit a specific server version using service geodatabase.

Image of edit with branch versioning

Use case

Workflows often progress in discrete stages, with each stage requiring the allocation of a different set of resources and business rules. Typically, each stage in the overall process represents a single unit of work, such as a work order or job. To manage these, you can create a separate, isolated version and modify it. Once this work is complete, you can integrate the changes into the default version.

How to use the sample

Once loaded, the map will zoom to the extent of the feature layer. The current version is indicated at the top of the map. Click "Create Version" to open a dialog to specify the version information (name, access, and description). See the Additional information section for restrictions on the version name.

Click "Create" to create the version with the information that you specified. Select a feature to edit an attribute and/or click a second time to relocate the point.

Click the button in the top left corner to switch back and forth between the version you created and the default version. Edits will automatically be applied to your version when switching to the default version.

How it works

  1. Create and load a ServiceGeodatabase with a feature service URL that has enabled Version Management.
  2. Get the ServiceFeatureTable from the service geodatabase.
  3. Create a FeatureLayer from the service feature table.
  4. Create ServiceVersionParameters with a unique name, VersionAccess, and description.
    • Note - See the additional information section for more restrictions on the version name.
  5. Create a new version calling ServiceGeodatabase.CreateVersionAsync passing in the service version parameters.
  6. Get the Name property from the ServiceVersionInfo of the version created.
  7. Switch to the version you have just created using ServiceGeodatabase.SwitchVersionAsync, passing in the version name obtained from the service version info from step 6.
  8. Select a Feature from the map to edit its "TYPDAMAGE" attribute and location.
  9. Apply these edits to your version by calling ServiceGeodatabase.ApplyEditsAsync.
  10. Switch back and forth between your version and the default version to see how the two versions differ.

Relevant API

  • FeatureLayer
  • ServiceFeatureTable
  • ServiceGeodatabase
  • ServiceGeodatabase.ApplyEditsAsync
  • ServiceGeodatabase.CreateVersionAsync
  • ServiceGeodatabase.SwitchVersionAsync
  • ServiceVersionInfo
  • ServiceVersionParameters
  • VersionAccess

About the data

The feature layer used in this sample is Damage to commercial buildings located in Naperville, Illinois.

Additional information

Credentials:

  • Username: editor01
  • Passowrd: editor01.password

The name of the version must meet the following criteria:

  1. Must not exceed 62 characters
  2. Must not include: Period (.), Semicolon (;), Single quotation mark ('), Double quotation mark (")
  3. Must not include a space for the first character
  • Note - the version name will have the username and a period (.) prepended to it. E.g "editor01.MyNewUniqueVersionName"

Branch versioning access permission:

  1. VersionAccess.Public - Any portal user can view and edit the version.
  2. VersionAccess.Protected - Any portal user can view, but only the version owner, feature layer owner, and portal administrator can edit the version.
  3. VersionAccess.Private - Only the version owner, feature layer owner, and portal administrator can view and edit the version.

Tags

branch versioning, edit, version control, version management server

Sample Code

EditBranchVersioning.xamlEditBranchVersioning.xamlEditBranchVersioning.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<UserControl
    x:Class="ArcGIS.UWP.Samples.EditBranchVersioning.EditBranchVersioning"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock
                    FontWeight="SemiBold" Text="Click to select a feature, then change its damage type." TextWrapping="Wrap" />
                <TextBlock x:Name="CurrentVersionLabel"
                    Margin="5"
                    Text="Current version:" />
                <Button x:Name="CreateVersionButton"
                    Content="Create version" IsEnabled="False"
                    Click="VersionButtonPressed" />
            </StackPanel>
        </Border>
        <Border x:Name="VersionCreator"
            Style="{StaticResource BorderStyle}"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            Visibility="Collapsed">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock
                    Grid.Row="0" Grid.Column="0"
                    Text="Name:" />
                <TextBox x:Name="NameEntryBox"
                    Grid.Row="0" Grid.Column="1"
                    Margin="5" />
                <TextBlock
                    Grid.Row="1" Grid.Column="0"
                    Text="Access:" />
                <ComboBox x:Name="AccessBox"
                    Grid.Row="1" Grid.Column="1"
                    Margin="5" />
                <TextBlock
                    Grid.Row="2" Grid.Column="0"
                    Text="Description:" />
                <TextBox x:Name="DescriptionBox"
                    Grid.Row="2" Grid.Column="1"
                    Margin="5" />
                <Button
                    Grid.Row="3" Grid.Column="0"
                    Margin="5"
                    Content="Create"
                    Click="ConfirmVersionClick" />
                <Button
                    Grid.Row="3" Grid.Column="1"
                    Margin="5"
                    Content="Cancel"
                    Click="CancelVersionClick" />
            </Grid>
        </Border>
        <Border x:Name="AttributePicker"
            Style="{StaticResource BorderStyle}"
            HorizontalAlignment="Left"
            Visibility="Collapsed">
            <StackPanel>
                <TextBlock
                    Margin="5"
                    Text="Click to move feature."
                    Visibility="Collapsed"/>
                <StackPanel Orientation="Horizontal">
                    <TextBlock
                        Margin="5"
                        Text="Damage:" />
                    <ComboBox x:Name="DamageBox"
                        Margin="5"
                        SelectionChanged="DamageBox_SelectionChanged" />
                </StackPanel>
                <Button x:Name="CloseButton"
                    Margin="5"
                    Content="Close"
                    Click="CloseAttributeClick" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

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