Forum Academy Marketplace Showcase Pricing Features

Modify standard address constraint

I have a repeating group with many conditions but I am having problem with the address constraint. Below is simple example with hardwired distance (5kms) but I need this to come from database.

When I change the ‘5’ for ‘do a search’ for. I cant seem to find the way to constrain and use the current Campaign within the repeating group (see below)

Now the only way I can get this to work is to use a filter, but I think this is adding a performance hit because it takes over 5 sec to load the repeating group (with very small test data)

You could either set a custom state to have the distance on page load (assuming it is able to be set at load time), or have a hidden input with the value as initial value.

Can also use a visible input, for example a slider:

Thx for ideas Nigel and mishave but custom state or input are page wide not specific to campaign record. Each campaign record has business address and distance fields which need to be compared to user address. If distance between the 2 addresses exceed distance field/variable then this record should not be shown in the repeating group

Hmmm tricky, the problem being the search constraint won’t allow the use of the other fields in the data being searched.

A workaround could be to constrain as much as you can, for example include a distance search over the maximum possible distance, to limit the number of records that the :filter has to work with.

A more involved workaround could be to precalculate four numbers to make a latitude/longitude “bounding box” that fully contains the circle, storing each of the numbers into the data record.

Then the search constraint filter out anything outside the box. It will have too many matches, but a lot less than the maximum distance.