AnsweredAssumed Answered

Adding feature layer to existing web map

Question asked by Dean.Wilson7232 on Mar 4, 2019
Latest reply on Apr 16, 2019 by Dean.Wilson7232

I'm having an issue adding a feature layer to an existing webmap.  Here's what I'm trying to accomplish.


I'm building a feature layer from a feature collection.  The attributes for the feature collection is coming out of a different service then arcgis server, (just a database table).  When building up the feature collection, It keeps shooting me in the foot saying no object id.  So I went ahead and told it to use a different field for the object id. here's a code snippet of my feature collection:

var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPolygon"

featureCollection.layerDefinition = {
"geometryType": "esriGeometryPolygon",
"objectIdField": "accountNumber",
"fields": [{
"alias": "Routing Number",
"alias": "Account Number",
"alias": "Parcel Number",


Now I'm getting/building up the attributes and adding them to the features array with these methods:

var featureLayer = new FeatureLayer(featureCollection,{
id: 'Ratio Viewer Results',
mode: FeatureLayer.MODE_ONDEMAND,
infoTemplate: new PopupTemplate({
accountNumber: "{accountNumber}",
routingNumber: "{routingNumber}"
});"layer-add-result", function(){

featureLayer.on("edits-complete", function(results){
console.log("Edits complete results: ", results);

function requestLayerData(){"URL to service", {
data: JSON.stringify(searchParams),
headers: {
"Content-Type": "application/json"
handleAs: 'json'

function requestSucceeded(response){
var features = [];

arrayUtils.forEach(response, function(item){
var attributes = {
"accountNumber": item.accountNumber,
"routingNumber": item.routingNumber,
"sidwellNumber": item.sidwellNumber,
var geometryQuery = new Query();
var geometryQueryTask = new QueryTask("URL to arcgis service");
geometryQuery.where = "MACCT = " + item.accountNumber;
geometryQuery.returnGeometry = true;
var geometry = {
"geometry": geoData.features[0].geometry,
"symbol": {

var graphic = new Graphic(geometry);
}, function(error){
console.log("Error in feature set request: ", error);
featureLayer.applyEdits(features, null, null);

function requestFailed(error){
console.log("Main Request errored: ", error);



and when I add the callback function to applyEdits, the results there are blank. Plus i have the edit-complete event hooked to this feature layer, but it doesn't fire at all. Thoughts?  Thanks in advance!






It looks like it's being added as a graphics layer and not a feature layer?  when I look at the map object, this layer isn't in the list of layerIds, but it's in the list of graphic layers.  Not what I want.  Any ideas?