Hi,
I'm trying to add some field values programmatically after feature is created. Code is working fine for feature class but not working with feature layer created from FeatureService.
After creating feature I assigned field value and can see feature is getting added in feature layer attribute table in Arcpro 2.7 but doesn't sync online. I manually saved all edit's but still data is not appearing in feature service. After refresh or zoom-in/out feature gets cleated from Arcpro attribute table also.
Here is my code:
{
var mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Contains("Map"));
if (mapProjItem == null)
return;
QueuedTask.Run(() =>
{
var theMap = mapProjItem.GetMap();
IEnumerable<FeatureLayer> featLayer = theMap.GetLayersAsFlattenedList().OfType<FeatureLayer>();
foreach (FeatureLayer item in featLayer)
{
var layerTable = item.GetTable();
_rowCreateToken = RowCreatedEvent.Subscribe(onRowCreateEvent, layerTable);
}
}
private Guid _currentRowChangedGuid = Guid.Empty;
private void onRowCreateEvent(RowChangedEventArgs args)
{
if (_currentRowChangedGuid == args.Guid)
return;
var row = args.Row;
row["fieldname"] = "Some Value";
_currentRowChangedGuid = args.Guid;
row.Store();
_currentRowChangedGuid = Guid.Empty;
}
Is there anything additional I need to do to save feature service edits?
Any help would be appreciated.
-Prashant