addFeatureAsync should return the OBJECTID of the added feature?

551
1
02-13-2021 02:03 AM
AmanSaryal
New Contributor

I have a geodatabase that I'm storing data to. When I add a new feature I need to know its OBJECTID right away as that is my only Primary Key in the table but the ListenableFuture currently returns a Void object.

Normally with SQLite, this is the expected behavior on record insertion with a returned ROWID (-1 on failure).

Am I missing something? Also, what would be a possible workaround?

I know I could maybe query for the latest OBJECTID after my feature is added but is there another way?

TIA

0 Kudos
1 Reply
RamaChintapalli
Esri Contributor

Hi AmanSaryal,

You should be able to get the OBJECTID from the feature attributes immediately after the feature is added to the geodatabase.

feature.getAttributes().get("OBJECTID")

 
If you are working with ServiceFeatureTable instead of GeodatabaseFeatureTable and want to get the ObjectID after performing applyEdits, then you can call `feature.refresh()` before getting the objectID from attributes.

Thanks

Rama

0 Kudos