My findTask is from the SAMPLE on Esri's website


I have incorporated into the project I am working on. I've looked over the code again and again and can't seem to figure out why this is not working.

Here is a link to the map.. http://www.co.frederick.va.us/planning/newmap1copy2.html

closed as off-topic by PolyGeo Apr 10 '16 at 1:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What do you mean by not working correctly? Is it returning bad results, no results when it should, erroring out, etc.? (Also, to fix how the code appears above, select all of it (from your doctype all the way down to your last div) and then click the code button (1's and 0's) above the editor textbox.) – Michael Todd Oct 8 '10 at 14:34
  • Michael, Thanks for the heads up on how to add code here. How can you tell its returning bad results? I am not seeing any results. Guess I need to figure out how to produce an error message. Thanks again for help. – Not to be named Oct 8 '10 at 14:48
  • @Not to be named Sorry I can't help, but that maps looks great, where did you get it if you don't mind me asking? – patrick Oct 13 '10 at 18:53
  • I started with this map and then added what I wanted from the different samples on ESRI's Javascript API Site.. help.arcgis.com/en/webapi/javascript/arcgis/demos/map/… – Not to be named Oct 14 '10 at 13:44
  • Did you ever figure this out? I am having the same problem on a 9.3.1 SP1 server - none of the services return any records for a find task, query works just fine. – Timothy Michael Feb 17 '11 at 15:41

Pro tip: use Fiddler to watch the traffic between your browser (viewer) and the server. Doing so produces this URL for your search query:


Opening that URL in your browser will show you the 500 error that is getting returned. 500 errors mean something's gone wrong on the server side. Change the output format to HTML and you get back some surprising results:


Why is that Feature ID -1? What is going on with that?

I would have expected something more like this:


Results with geometry.

Whatever is causing the Find task to return 500 errors / -1 unique IDs is what's wrong. You should be able to capture some info if you open up "rest.config" in C:\Inetpub\wwwroot\ArcGIS\rest, set the Logging/LogLevel to DEBUG, make the Find request that returns a 500 error and then consult restlog.txt for clues.

  • Thanks, I was looking at the Fiddler.. its way over my head right now.. I don't know why its returning a featureID -1.. – Not to be named Oct 14 '10 at 13:46
  • I added a bit about the log files for the REST endpoint. You may be able to find the error in the log files; the REST endpoint may be delegating to some other service (which would put the error in some other log file). – mwalker Oct 14 '10 at 16:49

The first thing that jumps out at me is that on your sample page you are searching for an owners name, but your find parameters are set for the PIN field.

findParams.layerIds = [5];
findParams.searchFields = ["PIN"];
findParams.outSpatialReference = map.spatialReference;

Try setting findParams.searchFields to your owner name field, unless you store owners name in the PIN field. It may not be the answer, but may be a pointer in the right direction.

  • Zahery, thanks for pointing that out. I have changed the code to reflect so that the user sees I am asking for a PIN instead. Haven't gotten it posted yet on the webserver. no access. – Not to be named Oct 8 '10 at 16:43
  • I've been looking through your code again, and I can't see where you are adding layer ID 5 into the map, unless I missed it. Are you going to search against this layer without displaying it? I would add it to the map, then test against it just to make sure all the search parameters are correct. – Zachary Oct 8 '10 at 18:04

Not strictly a "this is why it's failing" answer, but there's some good clues here.

The following is from Firebug:

callback: dojo.io.script.jsonp_dojoIoScript7._jsonpCallback
contains: true
f: json
layers: 5

The response is: dojo.io.script.jsonp_dojoIoScript7._jsonpCallback({"results":[]});

My immediate question/thought/suspicion is that either value for "layers" is wrong, or the value for "searchFields" is wrong. You're definitely not getting data back, so it's not client-side code not dealing with the response correctly.

Follow-on bits:
If you start here with your own service definition, and use 5 for the layer, PIN for the search field, and 102113 for the spatial reference you get a little more info. I searched for 54A, and got results back... kind of. Specifically, I got 83 results all with a FeatureId of -1. Does the underlying layer for layer id 5 have a FeatureId field?

Edit: Duh. I could have looked at the specification. Yep, there's an ObjectId.

Further: The query functionality is fine. It's only "Find" that's failing. That's genuinely strange. I'd be tempted to suggest rebuilding / republishing the service - I don't know if this is based on MSD or MXD, or what the underlying data sources are, but there's something interestingly confused.

  • Herb, thanks for pointing that out. I had forgotten the change the html code to reflect what I wanted users to input. I have changed that so its for the PIN instead. I am still getting no results. – Not to be named Oct 8 '10 at 16:44
  • It was originally based on an MXD.. Is FeatureId an invisible field? I don't see it anywhere in the data.. When I do a query on the ObjectID I get results with no negative numbers at least 5-6 digits.. so I am guessing that is working okay.. – Not to be named Oct 14 '10 at 13:12
  • "Feature Id" is just what what it's called by the find task. The actual output should be something like: Feature ID: 12 Field Name: OBJECTID Layer: Parcels OBJECTID: 12 Assuming you'd searched on objectid field, which doesn't work, either. In fact, find doesn't seem to work for any of the layers you've got there, which is troubling. – Herb Oct 14 '10 at 14:19
  • "Find" should then list the names / values of all the other fields. I verified that it doesn't work on any of the existing layers - you get just Feature ID: -1; Field Name: OBJECTID; Layer: <LayerName> – Herb Oct 14 '10 at 14:58
  • Last stab at this, before I go nutso; You've got an MXD, how is the underlying data stored? Did you load it into a file geodatabase, or is it shapefiles by some chance? – Herb Oct 14 '10 at 15:02

I hate to resort to "Upgrade to the latest version" as a solution, but what version and edition (Java or .Net) is your ArcGIS Server instance? I'm guessing 9.3 or earlier based on this lack of a "currentVersion": <currentVersion>, in the response to


If your AGS instance is indeed 9.3 and Java, this ESRI forum thread seems to indicate that an upgrade to 9.3.1 could be a fix. Also some related fixed NIMs at 9.3.1

  • NIM040198 - When using the REST API in ArcGIS Server for Java platform, Query, Find or Identify operation does not return Hebrew characters correctly in a JSON response. HTML output is correct.
  • NIM040199 - When using a Unicode datasource in a Map Service, REST API in ArcGIS Server for Java platform does not return non-English characters correctly in JSON response for Query, Find or Identify operation. HTML output is correct.

Who knows if this is related to the bizarre "Feature ID: -1" issue, but as Herb and mwalker note, that is very strange.