I am trying to clear out graphics on a graphicsLayer so that I can get a new selection. Everything works with my Query task but I can't seem to clear out the old results. All I end up doing is adding to the new results. I've tried a lot of different stuff but it is not working. How can I do this? I thought a graphics layer would allow me to do this and seems to be my best choice since I have a couple of other layers I want to be able to filter as well as different results.I tried up at the top putting the code up top where I add in some ArcGISDynamicMapServiceLayers but in my function it does not recognize my add layer and just bombs out. Works in my function though. However, I have a feeling it is creating multiple instances of otherRetailers.//Where should I put this in my code. otherRetailerLayer = new esri.layers.GraphicsLayer();otherRetailerLayer.id = 'otherRetailers'; map.addLayer(otherRetailerLayer);//Why does this not clear out my layer?map.graphics.clear(otherRetailerLayer); function showCEResults(featureSet) { // Clear Datagrid //create an empty store and then bind to grid var emptyCells = { items: "" }; var emptyStore = new dojo.data.ItemFileWriteStore({data: emptyCells}); grid = dijit.byId('gridCE'); grid.setStore(emptyStore); //alert ("Found InfoTemplate"); //Popup window settings var content = "<b>FID</b>: ${FID}" + "<br><b>MALLID</b>: ${MALLID}" + "<br><b>Mall Grade</b>: ${MALL_GRADE}" + "<br><b>District</b>: ${DISTRICT}" + "<br><b>MALL NAME</b>: ${MALLNAME}"; var infoTemplate = new esri.InfoTemplate("${DIVISIONNA}", content); var symbol = new esri.symbol.SimpleMarkerSymbol({ "color": [120,120,120,255], "size": 8, "type": "esriSMS", "style": "esriSMSSquare", "outline": { "color": [0,0,0,255], "width": 2, "type": "esriSLS", "style": "esriSLSSolid" }}); var symbolRedShinyPin = new esri.symbol.PictureMarkerSymbol({ "angle": 0, "xoffset": 0, "yoffset": 12, "type": "esriPMS", "url": "http://static.arcgis.com/images/Symbols/Basic/RedShinyPin.png", "contentType": "image/png", "width": 18, "height": 18 }); var symbolShinyPin = new esri.symbol.PictureMarkerSymbol({ "angle": 0, "xoffset": 0, "yoffset": 12, "type": "esriPMS", "url": "http://static.arcgis.com/images/Symbols/Basic/ShinyPin.png", "contentType": "image/png", "width": 18, "height": 18 }); //alert ("Found DataGrid and Graphics"); var dataForGrid = []; var temp = ""; var varRetailer = ""; //remove all graphics on the maps graphics layer otherRetailerLayer = new esri.layers.GraphicsLayer(); otherRetailerLayer.id = 'otherRetailers'; map.addLayer(otherRetailerLayer); //map.graphics.clear(otherRetailerLayer); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = featureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; varRetailer = resultFeatures.attributes.RETAILERID; if (varRetailer == "3000"){ resultFeatures.setSymbol(symbolRedShinyPin ); } else { resultFeatures.setSymbol(symbolShinyPin); } resultFeatures.setInfoTemplate(infoTemplate); otherRetailerLayer.add(resultFeatures); //Put values in array for datagrid var attValues = resultFeatures.attributes; dataForGrid.push(attValues); }; //var grid = registry.byId("gridCE"); var data = { identifier : "FID", label : "FID", items : dataForGrid }; var store = new dojo.data.ItemFileReadStore({data: data}); grid.setSortIndex(2,"true"); //sort on the state name grid.setStore(store); grid.on("rowclick", onRowClickHandler); //window.map.centerAndZoom(graphic.geometry); }