Search list of rest api data

Hello! I'm working on a project, where I need to implement a searching functionality to a table. Its a reactive web app that currently gets data from a json file (temporary). I successfully get the data to display on the table but I'm having quite a lot of problems implementing the search functionality to the table. I unfortunately cannot share the .oml because it is a client project.

So, tl:dr is: How can I implement a search functionality to a list in a local variable? I have tried the listfilter option but I didn't get it to work.

Hi Ronivil,


To help you, I need some more information. What does the list structure look like? Can you share the logic you tried to use with the list filter (I think this should be the way to go), How do you transform your JSON to a list?


Gr

Ronivil,

how did you implement the ListFilter, can you show the actions you took in that process?

Regards

Hello José Gonçalves and Jochem Vlug and thanks for your answers!
My ListFilter condition looks like this: 

Index(mockDataAction.testing.Results.Current.Profile.LastName, Client.SearchWord, ignoreCase:True) <> -1

I attached a .png to show my action where I'm trying to implement the search. I have deserialized the json and its working fine.

EDIT: The json file contains 2 objects where I want obviously filter the correct objects according to the users input

action.png

Hi,

I think before ListAppendAll, you need to Clear the list first.

Regards,

Khuong

Thanks for the suggestion, but i dont see a reason to clear the list before the append. Correct if im wrong of course!

Hi Ronivil,


Thank you for sharing the action flow, I think I see your issue.

1) Please make sure when you are retrieving data from a server call that the data is fetched and the list is not empty!

2) Assign the whole output to a local variable, in which you will perform the listfilter.

3) In the listfilter assignment, you check the current Profile.LastName but not the whole set, rendering the filter pretty much useless. Either iterate over all results or use the whole list as a filter.

4) As Khuong mentioned, it is a good practice to clear previous results before appending to prevent contamination of results.


Hope this helps!


Gr


Thanks for your message! The data is fetched correctly and i can see the data in the screen and also in the debugger. Could you provide an example of the logic? I'm still a beginner in outsystems so an example would help me alot!

Did you refresh the container where the data is displayed?

yes, i have the client action binded to a button and the refresh is happening that way

Sorry for dark mode, I hope this is clear for you:

I implemented my suggestions, further more the function for the filter is:

Index(LastName, Client.SearchWord, ignoreCase:True) <> -1


Good luck!


Thanks for your suggestion! I tried to implement the solution to my app but now, im getting nothing with one of the objects lastname but i then get both results when trying the second objects last name

It should be noted that this filter only works for 1-to-1 matches, it does not behave as a LIKE filter when you formulate it like this.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.