I am having an issue with printing using the ExportWebMap service as follows:
When I print the map, the printed content is not the same as the content displayed in the map application. Specifically, I am getting features from my feature layer displayed on the printed output which don't appear in the map application. I am using a feature layer and a definition expression -- which I am setting in my application. The definition is respected in the application, but I am picking up what seem to be random additional features which don't meet the definition expression in the printed output. In fact, I can see these in the WebMapAsJson in the browser which is sent to the print service.
In troubleshooting, I moved the definition expression to the map/feature service. Again, the expression is respected in the raw service, in my application, but not in the printed output. I am still getting seemingly random features in my map output that aren't included in my map application.
The only other thing that might be a factor here is that in the WebMapAsJson, the erroneous/extra features do not contain the attribute which I am using for rendering (that is, the feature attribute object doesn't contain the attribute I am using for rendering). This is because I am adding this on the client side in my application. So the feature isnt being rendered on the client, but it is being rendered in the printed output.
Can anyone provide any insight as to how I might address this issue?
A little more information here... It seems that if my definition expression is relatively short (e.g. "BL_ID in ('0001','0002','0003'), the output matches the map in my application. If the definition expression is relatively long (e.g. 70ish building IDs), the the output fails. I am not sure where things start to go sideways. Is there a character limitation of the definition expression?
Regarding your definition expression, I tried it with 100 unique IDs on one of my map services, totaling 951 chars. The export/print service honored the definition expression without any issues.
I have an existing FeatureLayer "template" that I mash-up with JSON data from a SQL query (using shared PKs).
Since I'm simply setting a renderer, adding my data field to the definition expression is not honored. I haven't tried this, but I think joining the data with a dynamic layer would work such that a definition expression is honored on the data fields not in the map service:
It sounds like we are doing something very similar. I am in fact mashing up some local data with a feature layer using shared PKs. I think the problem with the renderer arises when some of the features dont have any local data. This doesnt seem to cause a problem when rendering on the client, but it does appear to cause a problem when the WebMapJSON is sent to the print task. If the feauture doesnt contain the renderer attribute, it seems a default of zero is assumed on the server side. I dont want to provide a default value of say zero, as I am using a class break renderer where zero is a valid data value. Maybe I need to drop in null/NULL here? I will take a closer look at the sample/references you provided. Thank you.