Select to view content in your preferred language

addFeature vs. updateFeature

433
3
Jump to solution
01-08-2019 03:51 PM
MichaelDavis3
Regular Contributor

I'm updating some apps from runtime 2.5 to 100.4


It looks like the AGSGDBFeatureTable saveFeature method has been replaced by the AGSGeodatabaseFeatureTable addFeature and updateFeature methods.

Do I need to detect if the feature is "new" and use the appropriate add or update method now?

0 Kudos
1 Solution

Accepted Solutions
SuganyaBaskaran1
Esri Contributor

That is correct. For new features, you would first create a feature using one of the create methods on AGSGeodatabaseFeatureTable. Once created, you can add the feature to the table using the add method. 

For existing features, you typically get a reference to the feature first (query, identify etc), edit and call the update method. 

Hope that helps. 

View solution in original post

3 Replies
SuganyaBaskaran1
Esri Contributor

That is correct. For new features, you would first create a feature using one of the create methods on AGSGeodatabaseFeatureTable. Once created, you can add the feature to the table using the add method. 

For existing features, you typically get a reference to the feature first (query, identify etc), edit and call the update method. 

Hope that helps. 

MichaelDavis3
Regular Contributor

Thanks - I have tons of generic edit views where I might have either a new or existing feature that is being edited.  Previously the saveFeature method worked fine for either, but I guess I'll have to use AGSGeodatabaseFeatureTable's canUpdateFeature to check if it is new (not updatable) or not and take the appropriate route.

Am I assuming correctly that a new feature will return a NO when I check with canUpdateFeature?

0 Kudos
SuganyaBaskaran1
Esri Contributor

Yes, it would. A feature created just exists in memory whereas an update operation is done on the table. canUpdateFeature would return true after you've added the feature to the table using add method. 

0 Kudos