Update attributes with applyEdits() [NEED HELP]

9784
16
Jump to solution
06-13-2012 12:50 PM
SachaTousignant
New Contributor III
Hello everyone,

I'm currently trying to update a feature layer without attribute inspector (gave up with the attribute inspector / editor since I had no control over it for the interface).

My first problem is the following :
I have an error with my applyEdits : Invalid graphic features, Invalid parameters
And I just found out why, it's because one of my field is a date with a format like 2012/06/13 04:00:00 UTC and I was trying to update it with a 2010-01-01 format.

My second problem is the following :
So without the date, the applyEdits goes into the onResult but, no changes have been made to the feature layer and it doesn't even trigger the editComplete nor editsStarting events from the feature layer.

Here's the code :
feature.attributes={OBJECTID:gr.attributes.OBJECTID,      RESP_PERQ:strRespPerq,      RESULT:strResultatF,      NBR_PLANTS:strNbrPlant,      RAISON:strRaison,      CONFUSION:strConfusion};  featureLayerFiche.applyEdits(null, [feature], null, new AsyncResponder(onResult, onFault));              function onResult():void     {      Alert.show("ONRESULT");     }          function onFault(info:Object, token:Object = null):void     {      Alert.show(info.toString());     }  // LOAD OF CODE ... // <esri:FeatureLayer id="featureLayerFiche"         mode="snapshot"         outFields="[OBJECTID, IDFICHE, NM_MUN, UNITE, DISTRICT, DATEFICHE, RESP_PERQ, DATE_PERQ, RESULT, NBR_PLANTS, RAISON, CONFUSION]"         selectionComplete="myFeatureLayer_selectionCompleteHandler(event)"         editsComplete="featureLayerFiche_EditsCompleteHandler"         editsStarting="featureLayerFiche_EditsStartingHandler"         fault="featureLayerFiche_FaultHandler"         disableClientCaching="true"         url="http://myserver123/ArcGIS/rest/services/geocisaille/FeatureServer/1"/>  // LOAD OF CODE ... // 


So I'm just wondering why it doesnt trigger my events if it went into the onResult function.

*Also, I tried to place the [feature] in the delete array and it works, so I can delete feature with no problem.*

Any help would be greatly appreciated, since there's not alot of docs about it.
Lmk if you need more informations.
Tags (2)
0 Kudos
16 Replies
BjornSvensson
Esri Regular Contributor
Yes, it works with editor, tho I gave up on it since I had no control over the interface.


Are you familiar with the skins of Editor and other components?  It gives you a lot of control over the the UI...
0 Kudos
SachaTousignant
New Contributor III
Are you familiar with the skins of Editor and other components?  It gives you a lot of control over the the UI...


Really not but, I'm feeling like I'll have to get used to it... since I'm having weird error with my applyEdits()

But for examples, can you do the following :

1-Field inspector enabled but not editable?
2-Field inspector disabled but only the textinput, not the label with it and it's container?
3-Program so you can change a certain combobox, it disables another field inspector?
4-Easy to customize the interface as much as the designer?


I feel like it's gonna be tough to work around all thoses, and I'd like to do way more than just thoses 4 points.
I'd really prefer that my update works, it'd be already all done..

Another reason why I really wanna do with applyEdits() is because of the fact that it seems like ARCGIS API for Flex isn't supporting having multiple editors at once, on 2 different feature layer.
0 Kudos
DasaPaddock
Esri Regular Contributor
Yes, it works with editor, tho I gave up on it since I had no control over the interface.
I don't really know how to check the HTTP requests, is it with HTTPFox or Charle proxy like you said?


Yes, or with Fiddler, etc.
0 Kudos
SachaTousignant
New Contributor III
Yes, or with Fiddler, etc.


Ok, i'll try it and keep you guys updated!
0 Kudos
SachaTousignant
New Contributor III
This problem is now solved! TY alot Dasa Paddock for your help!

With Fiddler2, I saw that my objectID in the result was at random, a number between -10000 and 10000.
It happened because I had : "OBJECTID" : "24" instead of : "OBJECTID" : 24

I didn't notice my OBJECTID was in a string due to graphicVariable.attributes.OBJECTID which is a string.

Thx again everyone!
0 Kudos
JFJF
by
New Contributor
Thank you for your solution.I have solved my problem which perplexes  me all the afternoon.
I don't understand why the 'OBJECTID' changed to  string yet.
Sorry for my bad english ,In China I don't see the same problem solution in Chinese Web,thank you again!
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