Add Where clause to Offline Download or Sync

10-02-2020 10:37 AM
MVP Regular Contributor

We have a situation where at times to working areas may be pretty close together, and when the occurs the offline area overlaps.  At times there may be a significant amount of data collected in one of these overlapping areas

So what is happening when a user wants to takes area 2 offline, they will also pull all of the data collected as part of area 1.  And when syncing between these two offline maps they are still including the other area.

What would be nice is if we could define a where clause as part of taking the map offline, so we only pull data associated to a specific project number.  

Is this possible?

Associated to this is that we were hoping to allow crews to collect existing data near the work areas (because this data is collected with GPS it is a chance to improve accuracy), so for this reason we give a good size buffer around our boundary when taking the project offline.



0 Kudos
2 Replies
Esri Regular Contributor

This is possible. You need to provide overrides when you create the offline map to download.

Check out the ApplyFeatureFilter method in this sample.

In short, you set up parameters as usual, then ask for an overrides object. In that overrides object, you can modify the specific GenerateGeodatabaseParameters for the layer(s) you're interested in.

GenerateGeodatabaseParameters has an Extent property (it can be any polygon), and a LayerOptions property. LayerOptions is a list of GenerateLayerOption objects, one for each layer in the service/geodatabase. The LayerOptions property lets you provide a WhereClause for that layer, as well as whether to use the Extent set on the GenerateGeodatabaseParameters object.

This bit of the API takes a minute or two to understand (and I recommend you look at the above sample), but it's really powerful and gives you layer-by-layer control over taking the map offline.

What I can't quite remember is whether, when you sync edits, any offline map creates and edits need to meet any Extent and WhereClause restrictions that were defined when the map was downloaded. Worth making sure. I have asked the team that built this and will confirm when I find out.

Hope this helps.

MVP Regular Contributor

This looks like the path forward.  Thanks (will mark correct once we have implemented)

0 Kudos