Dear all,
i am trying to update a feature using feature service.My geodatabase is versioned.below is my code
var UpdateAttr = {
اسم_الشركة: test_2,
Mineral :validFeature.attributes.Mineral,
Geologist : validFeature.attributes.Geologist,
Duration : validFeature.attributes.Duration,
End_Date : validFeature.attributes.End_Date,//"",
Decision_Type :validFeature.attributes.Decision_Type,//"",
Location : validFeature.attributes.Location,//
Decision_Date : validFeature.attributes.Decision_Date,//"",
Decision_No : validFeature.attributes.Decision_Date,//"",
Visible_Code :validFeature.attributes.Visible_Code,//"",
Emirat_Code : validFeature.attributes.Emirat_Code,//
Mineral_Code : validFeature.attributes.Mineral_Code,//"",
Complex_Code : validFeature.attributes.Complex_Code,//"",
City_Code :validFeature.attributes.City_Code,//"",
Status_Code :validFeature.attributes.Status_Code,
Emirate : validFeature.attributes.Emirate,*/
Governorate : "ddd",
};
var UpdateValidLayer = new esri.layers.FeatureLayer(featureServiceValidURl);
var MyUpdateGraphic = new esri.Graphic(null, null, UpdateAttr);
var updateFeatures = [];
updateFeatures.push(MyUpdateGraphic);
UpdateValidLayer.applyEdits(null, updateFeatures, null, function (addResults, updateResults, deleteResults) {
dynamicMapServiceLayer.refresh();
console.log("Apply Edits Successfully:");
alert("updated Successfully");
}, function (err) {
alert(err.message+"___"+err.code+"_________"+err.id);
console.log("Apply Edits Failed: ",err.message+err.code);
});
Always through error "Unabale to complete operation.Error Code is 400".i have this code many times in my other projects.But this time throwing error.
i also try to update feature using arcgis server webinterface.it works from the webinterface.so
Pls help.Thanks is advance.
Solved! Go to Solution.
Dear Robert
it works like the code below.Problem is is query tak.execute.For update delete and insert the feature layer should execute quer.like below code.
var queryTask = new esri.tasks.QueryTask(RestServiceUrl + "/0");//Query For Valid Licences
var query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "LicsNumber= '" + strLicsNumber + "'";
queryTask.execute(query, QueryResults);///Problem line for updating feature layer.
UpdateValidLayer.queryFeatures(query, QueryResults);...this line is correct
Nadir,
What is this?
Emirate : validFeature.attributes.Emirate,*/
That is not a proper comment and would be a syntax error.
Also when you get to the last property do not use a comma.
Governorate : "ddd",
dear Robert
I change the remarks but it is still throwing same error.
Thanks
Nadir,
1. Have you successfully updated a field that has it's name in a different language?
اسم_الشركة: test_2,
2. Is this a table you are updating and not a feature with geometry?
Dear Robert,
I update from web interface of arcgis server with the arabic name of field.Its updated successfully.But this is first time i am updating feature service having table name in arabic.the other thing i just want to upadate attribute vales of a feature not the geometry.i cant say this arabic name is the reason for throwing error.
Thanks
Dear Robert,
i put try catch and it is throwing the fallowing error.
Unable to complete operation.___400_________ObjectId field is missing.
In my table OBJECTID_1 is the objectID column.this can be the reason.
Thanks
Nadir,
You are doing an update so normally I would get the existing graphic and not create a new graphic. So the way I see it is that because you are creating a new graphic it is getting a new ObjectId and this is an issue.
Dear Robert,
This is my updated code.But it is throwing same error.Pls help.
function updateValidFeature(validFeature,strHello,strHello1){
try{
var UpdateValidLayer = new esri.layers.FeatureLayer(featureServiceValidURl);
var graphic = validFeature;
graphic.setAttributes({Governorate: "Riyadh",Status_Code:"2"});
var updateFeatures = [];
updateFeatures.push(graphic);
UpdateValidLayer.applyEdits(null, updateFeatures, null, function (addResults, updateResults, deleteResults) {
dynamicMapServiceLayer.refresh();
console.log("Apply Edits Successfully:");
alert("updated Successfully");
}, function (err) {
alert(err.message+"___"+err.code+"_________"+err.details);
console.log("Apply Edits Failed: ",err.message+err.code);
});
}
catch(Ex){
alert(Ex.message);
}
}
Dear Robert,
I try to update from web interface of arcgis server it through the same error.you can check this with attached image.What can be the reason.I tried to insert the new record and its inserted successfully.I face this problem updation and deletion of record.
pls help.
Thanks
Dear Robert,
i successfully update the record from arcgis webinterface.but still facing error updating from my code.
var UpdateAttr = {OBJECTID_1:validFeature.attributes.OBJECTID_1,اسم_الشركة: "test_25"};
var UpdateValidLayer = new esri.layers.FeatureLayer(featureServiceExpiredURl);
var feature =validFeature;// new esri.Graphic(null, null, UpdateAttr);
//graphic.setAttributes({OBJECTID :validFeature.attributes.OBJECTID_1,Governorate: "Riyadh",Status_Code:"2"});
var updateFeatures = [];
updateFeatures.push(feature);
UpdateValidLayer.applyEdits(null, updateFeatures,null, function (addResults, updateResults, deleteResults) {
//dynamicMapServiceLayer.refresh();
console.log("Apply Edits Successfully:", updateResults);
alert("updated Successfully");
}, function (err) {
alert(err.message+"_________"+err.code+"_________"+err.details+"_______"+err);
console.log("Apply Edits Failed: ",err);
});
this is my last code this is the error which i am facing "Cannot read property 'attributes' of undefined ".i dont understand which variable is udefined.pls help.