ApplyEdits missing attributes

1396
3
Jump to solution
11-17-2017 09:38 AM
JillianStanford
Occasional Contributor III

Good Morning,

I have the following piece of code that runs correctly on my development machine:

drawToolbar.on('draw-end', lang.hitch(this, function(evt) {
                drawToolbar.deactivate();
                this._editToolbar.deactivate();
                var fieldName = this.easementIdFieldName;
                var attr = {};
                attr[fieldName] = this._easementId;              
                var newGraphic = new Graphic(evt.geometry, null, attr);
                this._easementLayer.applyEdits([newGraphic], null, null);
            }));‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

It produces an applyEdits operation with the following form data:

f:json

adds:[{"geometry":{"rings":[[[-17575293.21213455,2433436.9187920587],[-17575121.228820905,2433112.061421838],[-17575321.87602016,2433064.2882791585],[-17575474.750076734,2433214.773678599],[-17575293.21213455,2433436.9187920587]]],"spatialReference":{"wkid":102100,"latestWkid":3857}},"attributes":{"EasementId":"25"}}]‍‍‍‍‍‍‍‍‍‍

The feature layer gets updated with the new feature, including attribute data.

When I move the app to my web server without changing any code the attributes disappear from the applyEdits operation.

The newGraphic variable is created correctly with the attribute parameter but it doesn't show up in the applyEdits form data:

f:json

adds:[{"geometry":{"rings":[[[-17579178.857595254,2454963.389069852],[-17579637.479764964,2449842.108174752],[-17580707.598160956,2452823.1522778696],[-17579178.857595254,2454963.389069852]]],"spatialReference":{"wkid":102100,"latestWkid":3857}},"attributes":{}}]‍‍

The feature layer gets updated with the new feature but without the attribute.

Javascript 3.2. ArcGIS Server 10.4.1.

Any ideas?

Many thanks!

Jill

0 Kudos
1 Solution

Accepted Solutions
JillianStanford
Occasional Contributor III

Thank you for your replies, Karen and Thomas!

The issue turned out to be that the field I was trying to update had somehow gotten set to editable = false.

What was confusing to me is that , non editable fields are removed from the attributes parameter but fields that don't exist are not removed.

Thanks again!

Jill

View solution in original post

3 Replies
ThomasSolow
Occasional Contributor III

I'm pretty clueless on what could be causing this.

It seems to me that it's probably a JS API/client-side issue.  If I understand correctly, the problem is that your attributes are not being posted to the feature service at all, which suggests they're being stripped before your request is sent.

One approach to figuring this out might be to manually send an applyEdits request without using esri/request.  The REST API documentation  describes how you can do this: ArcGIS REST API.  If you can successfully send an applyEdits request using XMLHTTPRequest/http library of your choice, then we can pretty sure this is an issue with the JS API.

It's strange that this is an issue in your production environment but not during development.  Obvious things to check might be browser versions and using the same webserver to host your app in both environments, little things like that.

KarenRobine
Occasional Contributor II

Definitely check it out using the Rest endpoint to see how it should work.   I do my graphic creation slightly different:

var graphic = new Graphic(
point,
this._projectPointsLayer.layerObject.symbol,
null,
this._projectPointsLayer.layerObject.infoTemplate
);

Afterwards I set my attributes. Something like the following:

attribute[curFld.fieldName] = parseFloat(geom.y).toFixed(curFld.numDecimalPlaces)

Then, I do something like the following:

graphic.setAttributes(attribute);

And finally:

lyr.applyEdits([graphic], null, null, lang.hitch(this, this._onApplyEditsFinish, lyr.type), lang.hitch(this, this._onError, lyr.type));

JillianStanford
Occasional Contributor III

Thank you for your replies, Karen and Thomas!

The issue turned out to be that the field I was trying to update had somehow gotten set to editable = false.

What was confusing to me is that , non editable fields are removed from the attributes parameter but fields that don't exist are not removed.

Thanks again!

Jill