Trouble getting attributes to go to the server

4475
3
Jump to solution
03-23-2015 11:00 AM
BobCrawford3
New Contributor III

Anybody else having trouble getting attributes to go to the server when creating records on a table hosted in a feature service?  Here is a code snippet for it:

ServiceFeatureTable _sft = await ServiceFeatureTable.OpenAsync(myFeatureServicePath);

GeodatabaseFeature gf = new GeodatabaseFeature(_sft.Schema);

gf.Attributes["WR_ID"] = 1;

// more attributes go here

if (_sft.CanAddFeature(gf))

{

  long oid = await _sft.AddAsync(gf);

}

FeatureEditResult fer = await _sft.ApplyEditsAsync(false);

foreach (FeatureEditResultItem ri in fer.AddResults)

{

  if (ri.Error != null || !ri.Success)

  {

  return false;

  }

}

return true;

I am running ArcGIS Runtime for .NET 10.2.5 with a feature service running on ArcGIS Server 10.2.2.

When I use fiddler, the ApplyEditsAsync only sends up the ObjectID attribute and you don't see any other attributes I might have in there.  I'm not sure why I don't get other attributes (like WR_ID, in this case) to go.  Any ideas?  Thanks!

0 Kudos
1 Solution

Accepted Solutions
BobCrawford3
New Contributor III

In case anybody is interested, this was a holdover from the 10.2.4 release of the SDK.  The solution was to specify values for the OutFields collection on the ServiceFeatureTable object.  Here is the laziest way I could come up with getting all of the fields to be available:

               _sft = await ServiceFeatureTable.OpenAsync(fl);

                if (_sft.OutFields == null)

                {

                    _sft.OutFields = new Esri.ArcGISRuntime.Tasks.Query.OutFields();

                }

                foreach (FieldInfo fi in _sft.Schema.Fields)

                {

                    _sft.OutFields.Add(fi.Name);

                }

View solution in original post

0 Kudos
3 Replies
BobCrawford3
New Contributor III

In case anybody is interested, this was a holdover from the 10.2.4 release of the SDK.  The solution was to specify values for the OutFields collection on the ServiceFeatureTable object.  Here is the laziest way I could come up with getting all of the fields to be available:

               _sft = await ServiceFeatureTable.OpenAsync(fl);

                if (_sft.OutFields == null)

                {

                    _sft.OutFields = new Esri.ArcGISRuntime.Tasks.Query.OutFields();

                }

                foreach (FieldInfo fi in _sft.Schema.Fields)

                {

                    _sft.OutFields.Add(fi.Name);

                }

View solution in original post

0 Kudos
SpencerSmith3
New Contributor II

Bob, you are awesome.  Thank you so much for this reply.  I have been attempting to get attributes to sync to my feature service for the past 4 hours and I couldn't figure out how.

Thank you so much for this.

ESRI, this is a problem that needs to be fixed, we shouldn't have to explicitly add the OutFields to a feature class when we are getting the table info from the Feature Service.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Thanks for the feedback. We recognised the 10.2.X OutFields design/behavior could be improved and have re-designed how this works for the next major release of ArcGIS Runtime SDK for .NET (codenamed "Quartz") which will be available later this year. In summary, we know which fields are required for rendering, labeling, etc and can manage that for you instead of you having to request specific or all fields.

Note the easiest way to get all fields in in 10.2.X is:

Snippet

myFeatureTable.OutFields = Esri.ArcGISRuntime.Tasks.Query.OutFields.All;

Cheers

Mike

0 Kudos