Hi all,
I am trying to batch insert features (parcels) into a feature layer using feature.applyedits. I am not successful yet. Any tips?
Here is what I got:
 on(dom.byId("createproject"), "click", function () {
                    $("#showattribute").css("display", "inline-block");
                    $("#gifspin").css("display", "inline-block");
                    projectarea.setAttributes({ "START_DATE": Date.parse($("#projectstartdate").val()), "FINISH_DATE": Date.parse($("#projectfinishdate").val()), "Name": $("#projectname").val(), "PROJECT_ID": $("#tesr").val(), "TREE_COUNT": $("#messages").text(), "ACRES": $("#area").text() });
                    
                    //Index array
                    arrayUtil.forEach(projectparcels, function (feature) {
                        feature.setAttributes({
                            "ID": $("#tesr").val(), "OWNER_NAME ": feature.attributes["OWNER_NAME"], "OWNER_ADDR": feature.attributes["OWNER_ADDR"],
                            "OWNER_CITY": feature.attributes["OWNER_CITY"],
                            "OWNER_STAT": feature.attributes["OWNER_STAT"], "OWNER_ZIP": feature.attributes["OWNER_ZIP"],
                            "PRCL_ID": feature.attributes["PRCL_ID"], "SITUSNUMBR": feature.attributes["SITUSNUMBR"], "SITUSSTRNM": feature.attributes["SITUSSTRNM"],
                            "SITUSSTRTY": feature.attributes["SITUSSTRTY"]
                        });
                        featurelayerParcels.applyEdits([feature], null, null, function () {
                            console.log("Parcel updated!");
                        },
                            function (error) {
                                console.log("Features not updated! ", error);
                            });
                    });
...});
					
				
			
			
				
			
			
				Solved! Go to Solution.
No. I am leaving OBJECTID aside because It is not necessary. Is that a problem?
No that is not an issue if that is the only value you are not providing.
Alex,
Wait a second in your original code post projectparcels was an array of graphics and latter in your back and forth you have
projectparcels = new Graphic(feature, symbol);Which means it is just one graphic. So I am not sure where your code is currently.
My current code:
function queryCallback(featureSet) {
                    var symbol = new SimpleFillSymbol(
                        SimpleFillSymbol.STYLE_SOLID,
                        new SimpleLineSymbol(
                            SimpleLineSymbol.STYLE_SOLID,
                            new Color([0, 0, 0, 0.65]), 2
                        ),
                        new Color([255, 255, 0, 0.35])
                    );
                    featureArray = featureSet.features;
                    arrayUtil.forEach(featureArray, function (feature) {
                        projectparcels = feature;
                        feature.setSymbol(symbol);
                        map.getLayer("GraphicsParcel").add(feature);
                    });
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		Alex,
So because you have:
projectparcels = feature;That means the projectparcels is an individual graphic.
Another issue is that a graphic can only exist once, meaning you can not add it to a graphicslayer and add the same graphic to your FeatureLayer. You will have to clone the graphic for one of the layers you are adding it to.
You something like this:
var newGraArr = []
...
//update the attributes
...
newGraArr.push(new Graphic(feature.toJson()));
...
featurelayerParcels.applyEdits(newGraArr, null, null, function () {
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		That was it! Thanks Robert
Also, an array of features is returned to the map as shown below:

the feature I add:
feature.setAttributes({
                            "ID": $("#tesr").val(),
                            "OWNER_NAME ": feature.attributes["OWNER_NAME"],
                             "OWNER_ADDR": feature.attributes["OWNER_ADDR"],
                            "OWNER_CITY": feature.attributes["OWNER_CITY"],
                            "OWNER_STAT": feature.attributes["OWNER_STAT"],
                            "OWNER_ZIP": feature.attributes["OWNER_ZIP"],
                            "PRCL_ID": feature.attributes["PRCL_ID"],
                            "SITUSNUMBR": feature.attributes["SITUSNUMBR"],
                             "SITUSSTRNM": feature.attributes["SITUSSTRNM"],
                            "SITUSSTRTY": feature.attributes["SITUSSTRTY"]
                        });the feature class fields:
query.outFields = ["OBJECTID", 
                  "OWNER_NAME", 
                  "OWNER_ADDR", 
                  "OWNER_CITY",
                  "OWNER_STAT", 
                  "OWNER_ZIP",
                   "PRCL_ID",
                  "SITUSNUMBR",
                 "SITUSSTRNM", 
                  "SITUSSTRTY"];