Hi there.

What I'm looking to do is have the options to search records within 50 miles,100 miles, 150 miles etc.

How would I do this?

Kind Regards

You will have to implement the location component, and know the coordinates of each of your other locations, calculate the distance somehow and then filter by that. There's no immediate easy answer, but it's completely doable.

Mariano Picco wrote:

You will have to implement the location component, and know the coordinates of each of your other locations, calculate the distance somehow and then filter by that. There's no immediate easy answer, but it's completely doable.

I've attached my OML on there you should see that my mobile app calculates the distance and displays the records in location order.

But what I'm trying to add is options to only show results for within 50 miles,100 miles, 150 miles etc depending on which option I click.

Any ideas?


Yep, many ideas. First one would be to have a drop down with the different distances you want, and on the OnChange action you'd have a List Filter which would act on the aggregate. You would probably need a local list, called Filtered Results or something like that.The Aggregate would be your original, unfiltered list, and then each time you change the drop down that would filter the Aggregate and assign those results to the FilteredList

Mariano Picco wrote:

Yep, many ideas. First one would be to have a drop down with the different distances you want, and on the OnChange action you'd have a List Filter which would act on the aggregate. You would probably need a local list, called Filtered Results or something like that.The Aggregate would be your original, unfiltered list, and then each time you change the drop down that would filter the Aggregate and assign those results to the FilteredList

Can you expand please? I'm not sure I understood.

If you can include screenshots that would be even better.

Kind Regards


Shaan Rashid wrote:

Hi there.

What I'm looking to do is have the options to search records within 50 miles,100 miles, 150 miles etc.

How would I do this?

Kind Regards

If you want to give the options to search within X amount of miles then you have to have some sort of input to choose how many miles, right?

So, I was saying, set up a drop down where you can choose the max amount of miles.

Then with that drop down value, filter the results of the aggregate

Mariano Picco wrote:

Shaan Rashid wrote:

Hi there.

What I'm looking to do is have the options to search records within 50 miles,100 miles, 150 miles etc.

How would I do this?

Kind Regards

If you want to give the options to search within X amount of miles then you have to have some sort of input to choose how many miles, right?

So, I was saying, set up a drop down where you can choose the max amount of miles.

Then with that drop down value, filter the results of the aggregate

Yes but how do I do this? 

Kind Regards


Well, I don't want to get too granular in my explanation, otherwise you might as well ask me how to use Outsystems. 

You get your results from an aggregate, this is your unfiltered list. Copy it over to a local variable, called FilteredList. This is the variable which will drive your results table!

Then, when someone changes the Limit of distance drop down, you will have an action which will filter that Filtered List. Since it changed, and this is mobile, your table will update!

One last caveat is, you don't want to filter an already filtered list, otherwise the more you filter the least results you'll get; so before filtering, you need to equal your Filtered List to your Original List (aggregate) and then filter. 


Hope it helps

Mariano Picco wrote:

Well, I don't want to get too granular in my explanation, otherwise you might as well ask me how to use Outsystems. 

You get your results from an aggregate, this is your unfiltered list. Copy it over to a local variable, called FilteredList. This is the variable which will drive your results table!

Then, when someone changes the Limit of distance drop down, you will have an action which will filter that Filtered List. Since it changed, and this is mobile, your table will update!

One last caveat is, you don't want to filter an already filtered list, otherwise the more you filter the least results you'll get; so before filtering, you need to equal your Filtered List to your Original List (aggregate) and then filter. 


Hope it helps

Are you able to send some pictures about what you're describing here please as I don't quite understand most of this explanation.

Kind Regards

Does anyone have any advice on this please?

My OML file is at the top of this page I'm trying to add checkbox options on the FJLocationList page that when clicked only displays records within 50,100 or 150 miles from current location. 

Kind Regards


Hi Shaan,

You have had plenty of advice !  What exactly are you not understanding ?


You say you want to add checkbox options to allow the user to select a distance.  Mariano suggested you could use a dropdown, alternatively you could use radio buttons or a button group, or you could even allow the user to enter any maximum distance he feels like traveling in an input.  

It's your party, just pick one of these methods, put it on your screen and bind it to a local variable in your screen.  If that part of the answer is a problem for you, you should consider (re)visiting some of the training material available.


So once you have decided on a method to ask the user what distance he wants to limit the results to, every time this value changes, you need to refilter your list.  

Currently you have bound the list widget to the aggregates output, so that forces you to refresh the aggregate every time the user changes this maximum distance.  Mariano suggested that you could copy your aggregate result to a local list, so you can just re-execute the filtering instead of refetching the data.

So you need to add a local variable to hold the filtered result list, and you need to set that as the source of your list widget.

In the on after fetch of the aggregate you need to add a listfilter node (maybe after the listsort) and only select the locations that have a distance less or equal to the local variable holding the maximum distance entered by the user, and then set the local list variable to the result of this filter node.

Whenever the user changes the distance he wants to use as a limit, you dont have to re-execute the aggregate, instead you can execute an action that only does these last 2 steps, filtering the aggregates output and assigning the local list.


One major concern I can see with your approach of calculating distances in the onAfterFetch, is that your list will only show correct and complete information when your aggregate fetches ALL location records from the database.  You have max records set to 50, is this enough ??


Hope this helps you to solve this,

Dorine

Hi Shaan Rashid,

The solution is already given by Mariano and Dorine, still if you are facing problem in understanding the flow I would advise you to revisit the online available course lectures.  

The attached solution is not to make you handicap in framing the solution but to help you to understand how to draft a solution.

See the attached .oml file


Hope this helps you!

Regards,

Benjith Sam