Update attributes (feature service)

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Update feature attributes in an online feature service.

Image of update attributes feature service

Use case

Online feature services can be updated with new data. This is useful for updating existing data in real time while working in the field.

How to use the sample

To change the feature's damage property, tap the feature to select it, and update the damage type using the drop down.

How it works

  1. Create a ServiceGeodatbase object from a URL.
    • When the table loads, you can get the domain to determine which options to present in your UI.
  2. Get a ServiceFeatureTable object from the ServiceGeodatabase.
  3. Create a FeatureLayer object from the ServiceFeatureTable.
  4. Select features from the FeatureLayer.
  5. To update the feature's attribute, first load it, then use the SetAttributeValue.
  6. Update the table with UpdateFeatureAsync.
  7. After a change, apply the changes on the server using ApplyEditsAsync.

Relevant API

  • ArcGISFeature
  • FeatureLayer
  • ServiceFeatureTable
  • ServiceGeodatabase

Additional information

When editing feature tables that are subject to database behavior (operations on one table affecting another table), it's now recommended to call these methods (apply edits & undo edits) on the ServiceGeodatabase object rather than on the ServiceFeatureTable object. Using the ServiceGeodatabase object to call these methods will prevent possible data inconsistencies and ensure transactional integrity so that all changes can be commited or rolled back.

Tags

amend, attribute, details, edit, editing, information, value

Sample Code

UpdateAttributes.xamlUpdateAttributes.xamlUpdateAttributes.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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.UpdateAttributes.UpdateAttributes"
             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;assembly=ArcGISRuntime">
    <RelativeLayout>
        <esriUI:MapView x:Name="MyMapView"
                        BindingContext="{x:Reference Name=ResponsiveFormContainer}"
                        Style="{StaticResource MapWithFormStyle}" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
            <StackLayout>
                <Label HorizontalTextAlignment="Center" Text="Tap to select a feature to edit." />
                <Picker x:Name="DamageTypePicker"
                        IsEnabled="False"
                        TextColor="Black"
                        VerticalOptions="CenterAndExpand" />
            </StackLayout>
        </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.