Edit with branch versioning

View inAndroidFormsUWPWPFWinUIiOSView 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. Tap "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.

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

Tap 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
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.EditBranchVersioning.EditBranchVersioning"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:resources="clr-namespace:Forms.Resources">
    <RelativeLayout>
        <esriUI:MapView x:Name="MyMapView"
                        BindingContext="{x:Reference Name=ResponsiveFormContainer}"
                        Style="{StaticResource MapWithFormStyle}" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
            <Grid>
                <StackLayout x:Name="DefaultView">
                    <Label Text="Tap to select a feature." />
                    <Label x:Name="CurrentVersionLabel" Text="Current version:" />
                    <Button x:Name="CreateVersionButton"
                            Clicked="VersionButtonClicked"
                            IsEnabled="False"
                            Text="Create version" />
                </StackLayout>
                <Grid x:Name="VersionView" IsVisible="false">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0"
                           Grid.Column="0"
                           Text="Name:" />
                    <Entry x:Name="NameEntryBox"
                           Grid.Row="0"
                           Grid.Column="1"
                           Margin="5" />
                    <Label Grid.Row="1"
                           Grid.Column="0"
                           Text="Access:" />
                    <Picker x:Name="AccessBox"
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="5" />
                    <Label Grid.Row="2"
                           Grid.Column="0"
                           Text="Description:" />
                    <Entry x:Name="DescriptionBox"
                           Grid.Row="2"
                           Grid.Column="1"
                           Margin="5" />
                    <Button Grid.Row="3"
                            Grid.Column="0"
                            Margin="5"
                            Clicked="ConfirmVersionClick"
                            Text="Create" />
                    <Button Grid.Row="3"
                            Grid.Column="1"
                            Margin="5"
                            Clicked="CancelVersionClick"
                            Text="Cancel" />
                </Grid>
                <StackLayout x:Name="AttributeView" IsVisible="false">
                    <Label x:Name="MoveText"
                           Margin="5"
                           Text="Tap to move feature." />
                    <StackLayout Orientation="Horizontal">
                        <Label Margin="5"
                               Text="Damage:"
                               VerticalOptions="Center" />
                        <Picker x:Name="DamageBox"
                                Margin="5"
                                VerticalOptions="Center" />
                    </StackLayout>
                    <Button x:Name="CloseButton"
                            Margin="5"
                            Clicked="CloseAttributeClick"
                            Text="Close" />
                </StackLayout>
            </Grid>
        </resources:ResponsiveFormContainer>
    </RelativeLayout>
</ContentPage>

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