Select to view content in your preferred language

Unable to upgrade to 4.24 as I cannot get rest/query to work in place of tasks/QueryTask

932
2
Jump to solution
10-06-2022 07:44 AM
JS_GilbertAZ
Occasional Contributor

I am having problems trying to replace the QueryTask for the 4.24 release, since tasks are no longer supported. I was able to do this for Identify and GeometryService tasks, but the query one is not working for me.
I am using the 4.23 version of the javascript api, and would like to upgrade to 4.24.  The issue here is that I cannot seem to create a constructor for rest/query, and my query code all is in a separate module, not within the require block. It's a fairly complex application, and the query module itself is over 1000 lines of code, dynamic html, etc. So I've always created a constructor for the querytask, and used that in the query module. That doesn't seem to be possible now, unless I'm missing something.

I made a stripped down version of this here: https://codepen.io/jsauder/pen/ExLXLYq just showing how the constructor for the query cannot be created, and passed to javascript outside of the require block. If there is a way to do this, I would greatly appreciate if anyone could share this. Thanks in advance for any assistance you may be able to provide.

 

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

The abbreviated setup below is probably along the lines of what you're looking for:

var queryTask;
var queryObj;

require(["esri/rest/query/executeQueryJSON","esri/rest/support/Query"], function(QueryTask, Query) {
	queryTask = QueryTask;
	queryObj = new Query();

	//other stuff
});

function runPolygonQuery(qIdx, qErr) {
	//other stuff

	queryTask.executeQueryJSON(sQryUrl+"/" + qIdx, queryObj);
)

 

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

The new query doesn't have a constructor, so instead of creating it using "new query", you have to use the createQuery method on a FeatureLayer.

0 Kudos
JoelBennett
MVP Regular Contributor

The abbreviated setup below is probably along the lines of what you're looking for:

var queryTask;
var queryObj;

require(["esri/rest/query/executeQueryJSON","esri/rest/support/Query"], function(QueryTask, Query) {
	queryTask = QueryTask;
	queryObj = new Query();

	//other stuff
});

function runPolygonQuery(qIdx, qErr) {
	//other stuff

	queryTask.executeQueryJSON(sQryUrl+"/" + qIdx, queryObj);
)

 

0 Kudos