Select to view content in your preferred language

FeatureLayer.applyEdits() always erroring on update when it actually worked

9745
12
Jump to solution
10-29-2013 10:33 AM
DaveHighness
Deactivated User
I am am using the FeatureLayer.applyEdits() method to update the attributes of a feature layer. The method is working and the attributes are being updated correctly but the callback always errors. When I look at the network response from the method it looks like the REST returned a correct 'operation completed' JSON object. The FeatureLayer.applyEdits() method seems to be erroring in parsing the REST response to the callback.

var feat = {     "attributes": {         "OBJECTID": 1094,         "Well_ID": 565656,         "GWIC_ID": "efg789",         "Geomethod_ID": 5,         "Township": "1N",         "Range": "1E",         "Section_": "1",         "Quarter_Section": "sw ne",         "Physical_Address_WellName": "Baxter and Puckett",         "Subdivision": "Test point 07",         "City_ID": 4,         "TotalDepth_ft_": "87"     } };  Feat_Layer01.applyEdits(null,[feat],null,function(res){     console.log('worked: '+dojo.toJson(res));     /*     if (res.length > 0){         if (res[0].success){             Ext.MessageBox.alert('MESSAGE', 'Updated well objectid: '+updres[0].objectId);         }         else {             Ext.MessageBox.alert('MESSAGE', 'Well update unsuccessful');         }     }     else {         Ext.MessageBox.alert('MESSAGE', 'Well objectid not found');     }     */ },function(er){     console.log('errored: '+dojo.toJson(er));     //Ext.MessageBox.alert('ERROR', 'Update Error:<br />'); }); 


It always goes to the Errorback function.

REST Response as seen in the Network Tab of JS development console:
{     "addResults": [],     "updateResults": [         {             "objectId": 1094,             "success": true         }     ],     "deleteResults": [] }


Is this a bug in the ArcGIS Server Javascript API? I can probably live with it for now since the edit is actually working but I'd prefer if the callback worked correctly.

Thanks, Dave
0 Kudos
12 Replies
BenFousek
Deactivated User
One thing I'm trying to remember is if I delete a well point, does the relationship class delete the related records or do I have to handle that in my code?


The database handles it. http://resources.arcgis.com/en/help/main/10.2/index.html#/Create_Relationship_Class/0017000000mn0000...

Expanding on my last post: if you don't update the actual feature object's attributes client-side when updating the database, the user is not going to see those updates, nor will the api (in a default info template for example) until the layer refreshes that feature for some other reason than an independent update. I can think of several instances where this could be a problem with feature layers.

One of the great things about a feature layer is that it's kinda like a feature class in ArcMap, in that it's features are the data (geometry and attributes). The api does a lot to reduce server calls by querying and such client-side when it can. If you load a feature layer in SNAPSHOT mode, you have essentially loaded the entire data set in the map just like adding a feature class in ArcMap.
0 Kudos
DaveHighness
Deactivated User
The update of the related tables worked perfectly by just creating a esri.Graphic() object and adding the attributes JSON object to it. The relationship classes are handling all the related table deletes as advertised.

I'm having trouble updating the wells feature class again (origin in the relationship) after I made some structural changes to the database, but it worked once and it should work again! Right?

Dave
0 Kudos
BertrandLAURANCIN
Esri Contributor

Hello,

Example 1 :

var map = new Map("map", {
basemap: "dark-gray",
zoom: 3,
});


layer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0");

attributes = { objectid: 119369, typdamage: "Update successfully" };

feature = new Graphic( null, null, attributes );

map.addLayer(layer);

map.onLayerAddResult = () => {
layer.applyEdits(null, [feature], null,
function (add, update, del) { 
console.log('success', update);
}); 
};

Exemple 2 :

var map = new Map("map", {
basemap: "dark-gray",
zoom: 3,
});


layer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0");

attributes = { objectid: 119369, typdamage: "Update successfully" };

feature = new Graphic( null, null, attributes );

map.addLayer(layer);

setTimeout(() => {

layer.applyEdits(null, [feature], null,
function (add, update, del) { 
console.log('success', update);
},
function (error) { 
console.log('error applyEdits \n', error);
});

}, 2000);

Bertrand