Select to view content in your preferred language

find task with semi-hard coded AND

1861
11
08-30-2016 08:38 AM
AdrianMarsden
Honored Contributor

Hi

I've got a web app that could potentially be used by three geographical bodies. The app features an address search, that hits a service with a single layer that has address records in.

When it is one body it is easy, the address service layer has features just for that body.

When it is one of three bodies I'd like to a) detect where they are coming from to keep a single code base - I'm sure I can do this by IP address range, login name or something

then

b) have the address layer to be used in the FIND task have all 3 areas addresses, but the find to work something like this plain English SQL;

Find where address contains <User inputted search string> AND area = <area defined by which body the user is from>

I'm not sure if this is possible - any ideas?  The find task has searchfields, and search text.  Currently my searchfields are three that contain different components of the address.  So searchFields = "Address1, Address2, Postcode" and searchText would equal "Magnolia Cottage" or something

So, if I expand the Searchfields to include "Area" (which may be "East Utopia", Gotham City", "Cursed Earth (north)" for the three bodies, I'd then have to tag one of these three onto "Magnolia Cottage" - which would fail.

I could query the incoming recordset, but this seems hard and wasteful, where a simple addition of a AND to the find task would work.

Any ideas?

ACM

0 Kudos
11 Replies
thejuskambi
Frequent Contributor

Its my fault. the FindTask returns FindResults[] so you would need to loop through that.

function showResults(results) { 
    var outResult = dojo.filter(results, function (res) {
        var feat = res.feature;
        return feat.attributes.LA == 'EDDC'; 
    });
.
.
.‍‍‍‍‍‍‍‍‍‍
AdrianMarsden
Honored Contributor

cheers - I was nearly there from a few other samples.  I'll give that a quick go before heading home.  Many thanks

0 Kudos