AnsweredAssumed Answered

Deferred Shows 'Extra' Results First Run

Question asked by mkoneya on Mar 13, 2017
Latest reply on Mar 14, 2017 by mkoneya

I am executing an Identify Task in ArcGIS Javascript.    The first time I open my HTML containing this code,   I get 'extra' results that should not be in their.    When I run the Identify again without reloading the HTML,   the results look correct.

 

Is something being cached on the Deferred?   How do I clear out any results so that this code executes without returning erroneous records?

 

Thanks,

 

Mele

 

 

 

function executeIdentifyTask (event) {
search.set("value", search.selectedResult.name);
var resultItems = [];
dom.byId("info").innerHTML = "";
event.result.feature;
identifyParams.geometry = event.result.feature.geometry;
identifyParams.mapExtent = map.extent;
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
var featureAttributes = event.result.feature.attributes;
for (var attr in featureAttributes) {
resultItems.push("<b>" + getFldAlias(attr) + ":</b> " + featureAttributes[attr] + "<br>");
}
var deferred = identifyTask
.execute(identifyParams)
.addCallback(function (response){
return arrayUtils.map(response, function (result) {
var feature = result.feature;
var layerName = result.layerName;
feature.attributes.layerName = layerName;
if (layerName === 'Brush Collection') {
//alert(feature.attributes['Area']);
resultItems.push("<b>" + "Brush Area: " + "</b> " + feature.attributes['Area'] + "<br>");
}
else if (layerName === 'Refuse Collection') {
//alert(feature.attributes['Collection Day']);
resultItems.push("<b>" + "Refuse Collection Day: " + "</b> " + feature.attributes['Collection Day'] + "<br>");
}
else if (layerName === 'Recycling Collection') {
//alert(feature.attributes['Collection Day']);
resultItems.push("<b>" + "Recycling Collection Day: " + "</b> " + feature.attributes['Collection Day'] + "<br>");
}
//return feature;

dom.byId("info").innerHTML = resultItems.join("");
});
});
}

Outcomes