What happened to definitionExpresison in 10.2 REST?

4401
8
08-15-2013 09:56 AM
DavidGreene
New Contributor III
I have an iOS Runtime SDK application which was running against 10.1.1.  The app would read read the definition query from the layer so that additional filters could be added and the original query restored.  Documentation was a little confusing as to when the query would override the definition query in the map/feature service and when it would append.  In any case, we got it working.

I setup a new 10.2 server and spent an entire day wondering why I was getting "Database error: invalid query" in my server logs and the feature services were not working properly.  Some tracing with WireShark showed that the layer definitions were being set to strings like "((null) or (null)) and (status = 'Complete')".  I know I need to change the App code to not produce queries like this but that is not the source of the problem.

The real problem is that the REST endpoints no longer give the JSON "definitionExpression" parameter and the HTML format says "Definition Expression: N/A".

Has 10.2 changed so that definition queries can no longer be read or overridden?  Are REST/Runtime SDK supplied layer definitions now always evaluated in addition to the published definition query?

Thanks for any input ...
0 Kudos
8 Replies
JanTeisinger
New Contributor II
We are having the same issue, no definition expression is being return from the endpoint in either format (HTML/JSON).

What has changed? In 10.1 this worked great and as with the previous poster, we are also dynamically reading and appending def query to our layers.

Thanks for any suggestions.
0 Kudos
RyanStrain
New Contributor III
I just upgraded to 10.2 and am also now receiving the "Definition Expression: N/A" in my REST endpoint. Has anything else been discovered concerning this issue? A workaround? Or are definition expressions no longer supported with map services? I'm using the setDefinitionExpression method in my code, and obviously now it is ineffectual.

I haven't found anything else discussing this issue other than this forum post.

Thanks.
0 Kudos
DavidGreene
New Contributor III
I have not gotten an answer from anyone.

We do need an answer, if nothing else, to clarify WHEN the definition expression is overridden and WHEN it is appended to.  There seems to be conflicts in the documentation.

I believe that it is Esri's intent to always keep the base definition expression as the publisher intended while the client defined expressions are appended to the default .. never overridden.  This action is preferred from a security aspect where a layer's definition expression may be used to filter out sensitive data (which is not really the best approach) and could also expose additional tables or functions that are internal to the database.

An exception would be using dynamic layers where the client/application is aware of the available datasets and fields.  In this case, a new layer is created and dynamically added to the map which can have a new expression defined.

I haven't tested any of these assumptions ...
0 Kudos
RyanStrain
New Contributor III
Thanks for the feedback David. Are you saying that you can work with Definition Expressions in the REST endpoint albeit without full functionality? All I receive is  "Definition Expression: N/A" even if I test the service by adding a basic definition expression before publishing.
0 Kudos
RyanStrain
New Contributor III
Here's a little more I've found on the matter- http://support.esri.com/en/bugs/nimbus/TklNMDkzMzQx
The bug report has been rejected. ESRI designed the REST endpoint to no longer contain the Definition Expression.

Although, I've also found somewhat conflicting documentation from ESRI- http://resources.arcgis.com/en/help/main/10.2/index.html#//00sq00000083000000  -- in the note section "Definition queries/query expressions cannot be modified programmatically through the map service. If you need to modify the query specified in your map service, you'll need to open the original map document, update the query, and overwrite your map service. For full instructions, see Overwriting a service in ArcGIS for Desktop."

I can't work with queries from the original map document either. So I'm going to have to figure out a different angle.
0 Kudos
DavidGreene
New Contributor III
While you can't modify the Definition Query that the layer was published with, you can still set a definition expression which gets appended to the default.  We have an IOS app which works against 10.1 and 10.2 REST services which sets additional filters on the layer based on the user's inputs.  The results will be only features which satisfy the published definition expression (which you can't retrieve in 10.2 REST) and the definition expression set on the feature layer in client code.

If the MapService allows layers to be added dynamically, then you might be able to create a new layer based off of one you want to change, set the definition expression, and add it to the map.  I haven't tried this method yet.
0 Kudos
RyanCoodey
Occasional Contributor III
OMG... so we just upgraded to 10.2.2 and a major piece of custom functionality in our WPF maps is not working because of this issue. We take the definition expression from one layer and append it to another using dynamic layers. Why would ESRI remove this, makes no sense? Why leave the object there if it is always going to be N/A?

So ESRI refuses to release fixes and service packs for 10.1 (hence our primary reason to upgrade), but removes functionality from 10.2... I'm totally between a rock and a hard place now.

Anyone hear any news on this issue? Any workaround to lookup a definition expression for a layer? Thanks much!
0 Kudos
RyanCoodey
Occasional Contributor III
Not much of a workaround but if it helps anyone else, for the time being we just copied the definition queries to the description and tweaked our app to read it from there. Ideally don�??t want to have to manage the query in two spots though.

Talked with a very helpful ESRI support person today and he is going to look into this and why that functionality was removed. Will update if I hear anything new.
0 Kudos