Hi, I am working on a feature layer that have setDefinitionExpression i.e filters data shown based on ID. Now i want to pre-populate attribute ID=xxx when a new object point is added. How do i do that

1444
1
11-25-2016 09:21 AM
satbirsingh
New Contributor II

var responsePoints = new FeatureLayer("http://myorgxxx/arcgis/rest/services/Secure/FeatureLayerName/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ['*']
});

//apply sql filter
var id= <%=GetID()%>;  //this comes from Asp.net server side
responsePoints.setDefinitionExpression("ID="+id);
map.addLayers([responsePoints]);

0 Kudos
1 Reply
satbirsingh
New Contributor II

I found answer to this:

first add  event to populate ID, when editing begins

dojo.connect(myFeatureLayer,"onEditsComplete",populateID);

//then add function

function populateID(addResults) {
if (addResults.length > 0) {
// this gets the corresponding graphic of the feature that was just added
var graphic = myFeatureLayer.graphics[OccurrencesFL.graphics.length - 1];
var ID = 123 ; (your id value here) 
graphic.attributes["ID"] =parseInt(ID);
myFeatureLayer.applyEdits(null, [graphic], null);

}

0 Kudos