Find Task on XY Event

I have XY data in SQL that I have added as an event layer to a map document. That .mxd was then used to create a map service. I can sucessfully use the Find Task in the REST services directory to find a specific record, but when I try to execute the find task using the Javascript API, it fails.

I exported my data to a personal geodatabase and created a map service off of the new feature class. The Find Task worked perfectly. It works if the source data of the map service is a feature class, but fails if it is an XY event layer. Can the Find Task be used on XY events or that a limitation of the task? Perhaps it is just a syntax error when defining my find parameters?

I have XY data in SQL that I have added as an event layer to a map document. That .mxd was then used to create a map service. I can sucessfully use the Find Task in the REST services directory to find a specific record, but when I try to execute the find task using the Javascript API, it fails.

I exported my data to a personal geodatabase and created a map service off of the new feature class. The Find Task worked perfectly. It works if the source data of the map service is a feature class, but fails if it is an XY event layer. Can the Find Task be used on XY events or that a limitation of the task? Perhaps it is just a syntax error when defining my find parameters?

XY Event layer is a temorary feature layer stored in memory or system "temp" folder. It is not persisent. Most likely your none local ArcGIS accounts (SOM, SOC, ArcGISWebServices) has no access to it and no surprise that you failed in getting findTask. Exported as permanent feature class is the right thing to do.

Mike,Thank you for your suggestions. I will look into the Make Query Table tool. Do you know why the find task will work on the XY layer when it is executed through the REST services directory but not through the Javascript API? I'm a little lost as to why the find task works in one but not the other. Since it works in REST, wouldn't that mean that the ArcGIS accounts have access to it? Or are they unrelated?Thanks!~Stephanie

As part of my troubleshooting, I added a line in there that checks if any results are returned and alerts me if nothing is found. It's not returning any results...I get the "nothing here" message. I have attached a screenshot that shows that I get results when running the find task from REST. I see that it has a FeatureID of -1. Would that cause a problem?Thank you for your help!

Attachments

I was hoping that a fresh mind after the weekend would help, but I'm still stumped.

I've used map services based on XY events in Flex without a hitch. I can query, etc. in my Flex apps and I can execute the Find Task just fine from the REST endpoint. This leads me to believe that it is a problem related to the javascript API or something along those lines.

I used Fiddler and I get the following when I try to execute the Find Task from my app:

esri.arcgis.gmaps._RestRequest._requestQueue.ArcGISJson_40631967163708915._callback({"error":{"code":500,"message":"Object reference not set to an instance of an object.","details":[]}});

Perhaps that is a clue to the problem, but I don't know what to do with it. Is this problem something that can be fixed (an error in my code, etc.)? Or is a Find just not going to work in Javascript (in other words I just need to scrap the find or switch to Flex)?

We have a couple different Flex apps using versions 1.2 and 1.3 of the ArcGIS for Flex API. We have used map services built on XY event layers in the past without any problems. For example, we use the Live Layer widget on XY layers -- that widget runs a query task and returns results just fine. Just to make sure there wasn't something wrong with the map service that I'm using in this Javascript project, I used it in a Live Layer widget in a test Flex app. It worked fine, so there shouldn't be anything wrong with the map service itself.

I worked with ESRI tech support and they concluded that the issue with the Find Task was related to the JSON output. The find task executed from within the ArcGIS Services Directory (REST) worked because the results are returned as html by default. The format can be changed to JSON by appending f=json to the end of the text in the address bar. When this was appended, the JSON output failed. The JavaScript API requires the JSON format, so that is why the find task was failing in my application. Why this fails is still not known. Tech support said that it looks like it is probably a bug in 9.3/9.3.1. The problem could not be replicated in an ArcGIS Server 10 environment. They will do further investigating.

I did some of my own troubleshooting on the find task during this past week. I tried 3 different data sources for my XY event layer in my map service (directly from SQL Server, a .dbf, and a personal geodatabase table). It appears that the find task works OK as long as the XY Event layer is not directly hitting a table in SQL Server. If the SQL table is exported to a .dbf or pgdb table and that exported table is then used to create the event layer, the find task worked.

In the meantime, tech support has helped me get the Query Task to work properly. I am able to use that instead of the Find Task in my application. The problem I was running into with the Query Task (from the query task example in the resource center - http://help.arcgis.com/EN/webapi/javascript/gmaps/samples/querytask/query_point.html) was incorrect locations of my results on the Google map. The results were being lined up across the top (see attachment). There is a line of code in the example that needed to be commented out.

query.queryGeometry = bounds;

Once I took out that line, my results displayed in the correct location.

If/when I learn anything more about the Find Task from ESRI tech support, I will be sure to post an update.