I am using ArcGIS Runtime SDK for .NET WPF 100.2 to develop mobile applications. I got a problem on “synchronize” function. When the app generates an offline database and then collect data, it works well, but the new collected data cannot be synchronized to our geodatabase when I press the “Synchronize” button. For the Synchronized function, I am using the code in this sample https://developers.arcgis.com/net/latest/wpf/sample-code/editandsyncfeatures.htm. The synchronization is successful, but I cannot find the new data in our geodatabase. However, after I edit these new data(such as changing some attributes’ values), it can be synchronized to geodatabase. It seems like “synchronize’ cannot identify new data, but edited data. Is it normal? In my code, the SyncDirection is Bidirectional, I run the code step by step and the synchronize always finished successfully. Does who know what reason causes this problem? How I fix it? Thanks
Make sure when you create a new feature you call it on ServiceffeatureTable as below:
Uri featureServiceUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/WildfireSync/FeatureServer/0");
ServiceFeatureTable _featureTable = new ServiceFeatureTable(featureServiceUri);
private async void GeoViewTapped(object sender, GeoViewInputEventArgs e)
MapPoint point = (MapPoint)e.Location;
var newFeature = _featureTable.CreateFeature();
newFeature.Geometry = point;
catch (ArcGISRuntimeException ex)
Hope that helps.
Thank you so much for your help, Nagma. I have tried your code, but doesn't work to me. I always got error messages. Please see the image. My code is like the follows. The new data can be saved to the offline database after the following code runs. But when I synchronized the offline geodatabse, the new data won't be synchronized to our geodatabase, but edited data can.
Private _feature As ArcGISFeature = Nothing
_feature = Offlinedatabase.GeodatabaseFeatureTables(0).CreateFeature()
_feature.Geometry = ptloc
Could you try to create a new feature without setting the attribute value and see if it is successful.
If not, I would suggest looking at the fiddler request when you call Await _feature.FeatureTable.AddFeatureAsync(_feature) for further troubleshooting.
How about if you use this service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/WildfireSync/FeatureServer/0"
Does it work ?
I am unclear, are you having an issue syncing or saving any new feature? In the thread title and description you mention sync issue, but this post makes it look like the issue is trying to save a new feature into an offline geodatabase. Also are you using the geaodatabase downloaded from the sample service, or do you have your own service?
I do not think the issue is with Editor Tracking because that exception is thrown when you try to set that attribute value, not on save.
Thanks for your reply. My issue is on sync. Actually, my sync is always successful when I debug my code. But I cannot see the new collected data in the geodatabase in our server when I check the data using ArcCatalog after I sync. However, after I edit the new collected data and sync it, it can be seen in the geodatabase. Adding new data uses code
Await FeatureTable.AddFeatureAsync(_feature); editing data uses codes
Await FeatureTable.UpdateFeatureAsync(_feature). I just guess that maybe AddFeatureAsync has some problems which let sync function cannot identify the adding changes, but UpdateFeatureAsync can. Not sure.
I have never observed this behavior, when I create a feature and a bidirectional sync runs it has always pushed that new feature up to the enterprise.
I am curious if after you have done the add if you can then query the feature table for the new feature. That would indicate that it truly is there. Another thing to check after the add would be the Geodatabase.HasLocalEdits property and the GeodatabaseFeatureTable.GetAddedFeaturesAsync. These would give you some insight as to if the table thinks it has edits
Thanks for your suggestions. I will try the things you recommended. I didn't try GetAddedFeaturesAsync, but after I added some new features, I closed my app, reopen it and the new data was there. And also I even reboot my computer, reopen my app and I still can see and identify my new data in the app, which means the data has been added into my local geodatabase already, right?
I have tried the code you mentioned, "Geodatabase.HasLocalEdits property and the GeodatabaseFeatureTable.GetAddedFeaturesAsync". The following code is the code in my WPF app. I added the "GetAddedFeaturesAsync() and Geodatabase.HasLocalEdits" after AddFeatureAsync. GetAddedFeaturesAsync() can return the new feature I added and Geodatabase.HasLocalEdits is True. But the new added feature still cannot be sync to my geodatabase. Is there any other thing I can test it?
Dim r As FeatureQueryResult = Await Geodatabase.GeodatabaseFeatureTable(0).GetAddedFeaturesAsync()
If Geodatabase.HasLocalEdits Then
Thanks for your help.
You have me stumped. I have always been able to sync new features. It definitely appears that the geodatabase thinks it has edits, so not sure why when it synced it would not send them. The behavior you see that it then works after an update is equally puzzling. Curious, are you seeing this with multiple DBs you created? Have you tried using a different service and running tests using a replica from that service.
Something else, do you have a definition expression tied to the feature layer, or is there a definition expression on the layers in the map document used in creating the service?