1 Reply Latest reply on Feb 10, 2012 7:19 PM by JNery-esristaff

    Unable to add new features to feature layer if feature class has subtype

      Hi guys,

      Im new to most of these technologies, so please bear with me. That being said I hope somebody can help! I am going to be as clear as possible so please let me know if something doesn't make sense.

      I am testing the WP7 SDK, and have created a simple "pothole reporting" application, which will allow a user to view a map with an ArcGIS Online basemap, and a feature layer containing the pothole data. They are able to add, identify and delete from the feature layer.

      Problem Summary: If my feature class has a subtype, I am not able to add a new feature to my feature layer - regardless of what property I pass to the Editor's Add command.

      Problem Details:

      If I create a feature class with no subtype, I am able to add, identify and delete features successfully, but as soon as I create a feature class with a subtype I am unable to add new features.

      According to the Resource Centers Concept page "Using The Editor":

      "Features can be added by using the Editor's Add command. It takes a single property indicating the type of feature or graphic to add to the map, which depends on the type of layer you're editing. When adding features to a FeatureLayer, the required parameter is a specific template or type ID. To determine the value when working with a FeatureLayer, see the service's web page; the value is the ID from the Types section."

      Here is my services page for my feature layer:

      Services Directory: http://mymachine/ArcGIS/rest/services/test2/FeatureServer/0

      Feature Layer: test2 (ID: 0)
      View In:   ArcGIS.com Map 
      Display Field: comment2
      Type: Feature Layer
      Geometry Type: esriGeometryPoint
      Type ID Field: status2
        OBJECTID (Type: esriFieldTypeOID, Alias: OBJECTID, Editable: False)
        status2 (Type: esriFieldTypeSmallInteger, Alias: status2, Editable: True)
        size2 (Type: esriFieldTypeSmallInteger, Alias: size2, Editable: True)
        comment2 (Type: esriFieldTypeString, Alias: comment2, Length: 50, Editable: True)
        date2 (Type: esriFieldTypeDate, Alias: date2, Length: 36, Editable: True)
        photo2 (Type: esriFieldTypeRaster, Alias: photo2, Editable: True)
        GlobalID (Type: esriFieldTypeGlobalID, Alias: GlobalID, Length: 38, Editable: False)
        ID: 1
        Name: New
          Name: New
          Drawing Tool: esriFeatureEditToolPoint
              status2: 1
        ID: 2
        Name: WIP
          Name: WIP
          Drawing Tool: esriFeatureEditToolPoint
              status2: 2
        ID: 3
        Name: Fixed
          Name: Fixed
          Drawing Tool: esriFeatureEditToolPoint
              status2: 3

      This is my feature layer declaration in XAML:

      <esri:FeatureLayer ID="Potholes" Url="http://mymachine/ArcGIS/rest/services/test2/FeatureServer/0" OutFields="*" />

      This is my editor declaration in XAML:

      <esri:Editor x:Key="MyEditor" 

      In my code behind (C#), I initialize my editor and feature layer:

      editor = LayoutRoot.Resources["MyEditor"] as Editor;
      editor.Map = MyMap;
      editLayer = MyMap.Layers["Potholes"] as FeatureLayer;

      I call the Editors Add command:

      if (editor.Add.CanExecute(???))

      According to the documentation "the required parameter is a specific template or type ID". I have tried passing:

      if (editor.Add.CanExecute(1))


      if (editor.Add.CanExecute("New"))

      Both variations return false, and I cannot add a feature.

      In the API documentation (http://help.arcgis.com/en/arcgismobile/10.0/apis/windowsphone/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Editor~Add.html)I also found the following:

      "If you are editing a FeatureLayer, the CommandParameter should be the feature type to use if you have feature types, or the template name if you only have templates defined. If you have multiple templates defined for each feature type, you can use an array object[] { featureTypeId, featureTemplateName } as parameter. If no template and/or feature type is specified, the default will be used. If the FeatureLayer is read-only, Add will not be supported."

      So then I also tried this:

      object[] myobj = new object[] { "1", "New" };
      if (editor.Add.CanExecute(myobj))

      This also returns false.

      I am at a loss here, any advice would be very much appreciated.