Select to view content in your preferred language

Add Feature

95
1
Tuesday
abufadzly
Emerging Contributor

Hello,

I'm trying to add a feature to FeatureService but I have error at addFeature function.

 
var _serviceFeatureTable = ServiceFeatureTable.withUri(Uri.parse("$link/0"));
 
final newFeature = _serviceFeatureTable.createFeature(
  attributes: {
    'FORMID': 'My',
    'POINT_TYPE': 'Titik Mula',
  },
  geometry: ArcGISPoint(
    y: 2.557467637393963,
    x: 101.76854136321231,
  ),
);
     
print("ADD FEATURE");
await _serviceFeatureTable.addFeature(newFeature);
print("APPLY EDIT");
final editResults = await _serviceFeatureTable.applyEdits();

  // Check if the edit was successful
if (editResults.isNotEmpty && editResults.first.error == null) {
  print("SUCCESS");
  print("New feature OBJECTID: ${editResults.first.objectId}");
} else {
  print("ApplyEdits error: ${editResults.first.error}");
}
 
But i get this error:
ArcGISException: code=3030; Geodatabase value is null.; OBJECTID cannot be null. Encountered on feature with ID of -9223372036854775808.
 
What did I do wrong?
Tags (1)
0 Kudos
1 Reply
JenMerritt
Esri Contributor

Hi there,

The expectation would be that the OBJECTID is generated when you perform the add feature call since ObjectIds are determined by the feature service.

Does your service definitely have the OBJECTID configured correctly? It should have the Field name OBJECTID (which from the exception you're getting I'd expect it will) and it should be of type "ObjectId".

Another thought - I take it since you are successfully creating the feature that you are awaiting a successful load of the service feature table before attempting any feature management?

A confidence check could be to play around with the data from our "Manage Features" sample. While the sample uses the service geodatabase approach, I was able to use your workflow above and substitute in the service URL from that dataset - and amend the attributes per the sample - and successfully add features.

Demo Service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0

Also unrelated but just an FYI - in your "// Check if the edit was successful" block - watch out for your null safety there, I think you need to ensure you're checking in all cases that editResults.isNotEmpty before accessing editResults.first.

I hope this helps.

0 Kudos