OnRowCreated on FeatureService

377
3
Jump to solution
06-28-2017 06:14 AM
Highlighted
New Contributor II

I am using the OnRowCreated event to set attribute values when a feature is created in the map. This is working fine when the data source is a feature class in a file geodatabase. It is, however, not working when the data source is a versioned feature service feature class (A utility network service). I get no errors, but my attributes is not populated with data after the OnRowCreated event is handled.

Suggestions?

BR Jonas

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

Reading the documentation lead me to the answer ArcGIS Pro Concepts > Edit Session.

When the datasource is a feature service, edit operations are performed in a short transaction. The result is that once the CreateRow method, which triggers the OnRowCreated event, is called on a feature, it will commit the new feature in one single call to the feature service before the OnRowCreated event is triggered. Further changes to the feature, done during handling the OnRowCreated event, will not be committed unless the Store method is called on the feature resulting in another call to the feature service.

I added this code after I have done the necessary changes to the row/feature in the OnRowCreated event handler:

var serviceConnectionProperties = rowChangedEventArgs.Row.GetTable()?
    .GetDatastore()?.GetConnector() as ServiceConnectionProperties;

if (serviceConnectionProperties != null){       
    rowChangedEventArgs.Row.Store();
}‍‍‍‍‍‍‍‍‍‍‍‍

This is however not optimal as creating the feature and adding my edits to the attributes are performed in two transactions.

Is it possible to accomplish this in one transaction? I have heard someone mention edit session variables that automatically can be set on the created features. Kind of like the edit user that is assigned to the feature.

View solution in original post

3 Replies
Highlighted
New Contributor II

Reading the documentation lead me to the answer ArcGIS Pro Concepts > Edit Session.

When the datasource is a feature service, edit operations are performed in a short transaction. The result is that once the CreateRow method, which triggers the OnRowCreated event, is called on a feature, it will commit the new feature in one single call to the feature service before the OnRowCreated event is triggered. Further changes to the feature, done during handling the OnRowCreated event, will not be committed unless the Store method is called on the feature resulting in another call to the feature service.

I added this code after I have done the necessary changes to the row/feature in the OnRowCreated event handler:

var serviceConnectionProperties = rowChangedEventArgs.Row.GetTable()?
    .GetDatastore()?.GetConnector() as ServiceConnectionProperties;

if (serviceConnectionProperties != null){       
    rowChangedEventArgs.Row.Store();
}‍‍‍‍‍‍‍‍‍‍‍‍

This is however not optimal as creating the feature and adding my edits to the attributes are performed in two transactions.

Is it possible to accomplish this in one transaction? I have heard someone mention edit session variables that automatically can be set on the created features. Kind of like the edit user that is assigned to the feature.

View solution in original post

Highlighted
Esri Regular Contributor

Hi Jonas,

What version of Pro and the utility network are you using here?

With regards to your other question, Editor Tracking can be used to record edits on datasets.

Reply
0 Kudos
Highlighted
New Contributor II

Hi Sean,

I am running Pro 1.4-beta.1.utility.network+build.7199.

Editor Tracking is only enabling standard fields to be auto updated. I am interested in custom fields for foreign keys to external systems that my add-in is integrating to. I need the features to be created and assigned a foriegn key in one transaction.

Reply
0 Kudos