Hi Robert,
I'm currently using eSearch 2.12 and am experiencing issues when using query layers with unique value settings. No options are returned even for small services. I have upgraded from 2.6 where I had no issue with the same query layers. Any advice would be useful.
cheers
Solved! Go to Solution.
Sure
Sorry for the delay. See below to test. Works at 2.6 without issue.
Rod,
What version of ArcGIS Server are you running on this server?
10.5.1 in prod and 10.6.1 in dev. I've tried both.
Rod,
There seems to be be something particular about QueryLayers that do not allow a query for distinct values to work when you are just querying for count. Using a standard layer has no issue at all with this same query. I have a simple code change for you that will get you past this issue. In my later versions I make a change that utilizes this type of query to expedite unique value results but never tested against query layers as I never use them.
In the widgets PagingQueryTask.js replace the existing execute function with this one:
execute: function () {
this.uniqueValues = [];
this.blankStringExists = false;
this.iStart = 0;
this.iMaxRecords = 0;
this.featuresProcessed = 0;
this.featuresTotal = 0;
this.isQuerying = true;
this.query.returnGeometry = false;
this.query.outFields = [this.fieldName];
if (this.version > 10.11) {
this.query.orderByFields = [this.fieldName];
}
this.query.objectIds = null;
if (this.defExpr && this.defExpr !== "") {
this.query.where = this.defExpr;
} else {
this.query.where = "1=1";
}
if (this.uri === '') {
this.emit('pagingFault');
return;
}
// console.info(this.uri);
this.queryTask = new QueryTask(this.uri);
if (this.version >= 10.1) {
//need to check if the feature count is over maxRecordCount
var cntQuery = new Query();
if (this.defExpr && this.defExpr !== "") {
cntQuery.where = this.defExpr;
} else {
cntQuery.where = "1=1";
}
cntQuery.returnDistinctValues = true;
cntQuery.outFields = [this.fieldName];
this.queryTask.executeForCount(cntQuery, lang.hitch(this, function(count){
this.featuresTotal = count;
if(count <= this.maxRecordCount){
this.allValues = [];
this.query.returnDistinctValues = true;
this.queryTask.execute(this.query, lang.hitch(this, this.onSearchFinish), lang.hitch(this, this.onSearchError));
}else{
delete this.query.orderByFields;
this.queryTask.executeForIds(this.query, lang.hitch(this, this.onSearchIdsFinish), lang.hitch(this, this.onSearchError));
}
}));
} else {
this.queryTask.executeForIds(this.query, lang.hitch(this, this.onSearchIdsFinish), lang.hitch(this, this.onSearchError));
}
},
Hi Robert,
Thank you for the update. Just tried this in WABD 2.12 with the test url and it still does not work. I get the "retrieving unique values" spinning around when I select a value. When I look at your code change, I don't see anything different to the original code. Could this be the issue.
cheers
Rod,
You must be placing the change in the wrong location or something. I have tested this with your data and it worked on my end.
I added it into the eSearch PagingQueryTask.js as requested. See below between the italic code.
startup: function () {
this.inherited(arguments);
this.query = new Query();
},
execute: function () {
this.uniqueValues = [];
this.blankStringExists = false;
this.iStart = 0;
this.iMaxRecords = 0;
this.featuresProcessed = 0;
this.featuresTotal = 0;
this.isQuerying = true;
this.query.returnGeometry = false;
this.query.outFields = [this.fieldName];
if (this.version > 10.11) {
this.query.orderByFields = [this.fieldName];
}
this.query.objectIds = null;
if (this.defExpr && this.defExpr !== "") {
this.query.where = this.defExpr;
} else {
this.query.where = "1=1";
}
if (this.uri === '') {
this.emit('pagingFault');
return;
}
// console.info(this.uri);
this.queryTask = new QueryTask(this.uri);
if (this.version >= 10.1) {
//need to check if the feature count is over maxRecordCount
var cntQuery = new Query();
if (this.defExpr && this.defExpr !== "") {
cntQuery.where = this.defExpr;
} else {
cntQuery.where = "1=1";
}
cntQuery.returnDistinctValues = true;
cntQuery.outFields = [this.fieldName];
this.queryTask.executeForCount(cntQuery, lang.hitch(this, function(count){
this.featuresTotal = count;
if(count <= this.maxRecordCount){
this.allValues = [];
this.query.returnDistinctValues = true;
this.queryTask.execute(this.query, lang.hitch(this, this.onSearchFinish), lang.hitch(this, this.onSearchError));
}else{
delete this.query.orderByFields;
this.queryTask.executeForIds(this.query, lang.hitch(this, this.onSearchIdsFinish), lang.hitch(this, this.onSearchError));
}
}));
} else {
this.queryTask.executeForIds(this.query, lang.hitch(this, this.onSearchIdsFinish), lang.hitch(this, this.onSearchError));
}
},
onSearchFinish: function (featureSet) {
var uVal;
Did you add this to the client/stemapp/widgets or a specific app that you are using (i.e. server/apps/[app#]/widgets?
The specific app in the server directory. I tried a couple to no avail.