Select to view content in your preferred language

Validate Where Clause of "Query" on a feature layer

1052
3
05-17-2014 04:38 AM
VivekPrasad
Deactivated User
Hello All,

Could anybody please let me know, if any out of box options are available with ArcGIS Server API for JavaScript, to validate the "Where" clause set for the "Query" object to run with "QueryTask" on a feature layer.

This option is available with ArcGIS Desktop - "Verify" button on "Select Features By Attributes" option.

Thanks in advance!

With Regards,
Vara Prasad.
0 Kudos
3 Replies
BenFousek
Deactivated User
I don't know of any out of the box verifier. But it's pretty easy to do it yourself against the service.

esriRequest({
    url: 'http://some_service/query',
    callbackParamName: 'callback',
    content: {
        f: 'json',
        returnGeometry: false,
        returnIdsOnly: true,
        where: where
    }
}).then(function (r) {
    if (r.objectIds) {
        console.log('valid query: ' + r.objectIds.length + ' results');
    } else {
        console.log('valid query: 0 results');
    }
}, function (e) {
    console.log('invalid query', e);
});
0 Kudos
VivekPrasad
Deactivated User
Hi Ben,

Thanks for the reply!

Actually I am aware of this. Just wanted to know availability of any out of box options. Thanks for your time.

With Regards,
Vara P
0 Kudos
JeffPace
MVP Alum
i use executefor

 try {
                        task.executeForCount(q, lang.hitch(this, function(count) {
                            if (count > 200) {
                                alert('More than 200 results, please enter more specific search criteria');
                            } else if (count === 0) {
                                alert('No results');
                            }

                            else {
                                if(count>1){
                                alert("Found " + count + " results, building summary");
                                }
                                task.execute(q, lang.hitch(this, "searchCallback", result.layers, layerdesc, result.titleField));
                            }
                        }));
                    }
                    catch (err) {
                        console.error("onTextSearch", err);
                    }
0 Kudos