Skip to content

Instantly share code, notes, and snippets.

@raykendo
Last active August 29, 2015 14:21
Show Gist options
  • Save raykendo/a107b9417d62839a02c5 to your computer and use it in GitHub Desktop.
Save raykendo/a107b9417d62839a02c5 to your computer and use it in GitHub Desktop.
ArcGIS JSAPI: Query Return Distinct - Precallback Request (V < 3.11)
require(["esri/request"], function (esriRequest) {
esriRequest.setRequestPreCallback(function(ioArgs){
// test if we're sending the request to a mapservice query
if(/query\/?$/.test(ioArgs.url)){
// if not requesting ObjectIds, count, or querying with a list of ObjectIDs, return distinct values.
if (ioArgs.content && !ioArgs.content.returnIdsOnly && !ioArgs.content.returnCountOnly && !ioArgs.content.objectIds) {
ioArgs.content.returnDistinctValues = true;
}
}
return ioArgs;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment