Using:
var queryTask = new QueryTask(layer.layerObject.url + "?returnDistinctValues=true");
But sometimes this works and sometimes it does not.
Are there any server settings for each layer (featurelayer) that needs to be specified precisely to make the returnDistinctValues=true work?
Using v. 3.10.