ArcGIS Pro SDK - Get field index of Hosted Parcel Fabric Featureclass

948
4
Jump to solution
09-02-2020 09:50 AM
MichaelSnook
Occasional Contributor III

Hi All,

I am trying to get a field index of a hosted Parcel Fabric featureclass in a mapview but it seems to be returning the 'wrong' index.  I have the Fabric hosted on Portal so we are editing the branch-versioned feature service.  When I call the typical methods to get the indexes:

var Parcels = MapView.Active?.Map.GetLayersAsFlattenedList().FirstOrDefault(fl => fl.Name == "Fabric Tax Parcels") as FeatureLayer;

int indx = Parcels.GetFeatureClass().GetDefinition().FindField("name");

or
int indx = Parcels.GetTable().GetDefinition().FindField("name");

...they both return 1.  1 is the correct index in the actual geodatabase featureclass, but in the mapview index 1 is GlobalId...so I'm getting globalid values returned rather than the desired 'name' field.

I'm assuming this isn't specific to the Parcel Fabric rather to branch-versioned/hosted feature services but I'm just using that as my example.

Any help would be great!

Thanks
Mike

0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Mike,

Are you hiding fields at the layer level?  That would explain why the field indices don't match up between the Layer and the feature class behind that layer.

Note that you can always reference a row value by using the field name rather than the field index.

var nameValue = myRow["name"];

--Rich

View solution in original post

4 Replies
RichRuh
Esri Regular Contributor

Mike,

Are you hiding fields at the layer level?  That would explain why the field indices don't match up between the Layer and the feature class behind that layer.

Note that you can always reference a row value by using the field name rather than the field index.

var nameValue = myRow["name"];

--Rich

MichaelSnook
Occasional Contributor III

Thanks Rich...my brain is still stuck on ArcObjects...didn't even think to directly reference the attribute name in the row cursor. 

BTW - I don't have any fields hidden at all...they are all defaulted as is when the Parcel Fabric was added via our Portal instance.

0 Kudos
MichaelSnook
Occasional Contributor III

Hi Rich,

While I have you...in the Pro SDK is there a way to quickly select all desired attributes without using a cursor to iterate over features.  I'm hoping there are some extension methods using lamda linq syntax:

myFeatureclass.attributes.select(x=>x.name).toList() or something similar would be awesome.

Thanks!

Mike

0 Kudos
RichRuh
Esri Regular Contributor

There isn't, sorry.

That might be good material for https://community.esri.com/community/arcgis-ideas 

--Rich

0 Kudos