Iterate through each element

Hi, so I was trying to make a Search function where I show the item the user is looking for, but I got lost with For Each loop, like how can I create the Logic behind it? I want to show that only item. Can someonle like explain to me to do it, btw I'm new to the platform, sorry if the question is kinda stupid 

Hi,

Your screenshot isn't giving s lot of information to work on.

To see how you can implement simple searching capabilities in a list screen, I would advice to schafold a list screen by dragging the entity on a UI flow,. Then inspect the screen and aggregate in the preparation to understand how to filter the results of an aggregate.

Regards,

Daniel

Hello Ali,

First I have a question. What is the source of your list? Is it an aggregate or database query? Is it a local list?

If it is an aggregate, then you can add a filter with the like keyword on the aggregate, and simply refresh the aggregate on each search. -> There is actually an accelerated process available in OS where you simply drag and drop an entity to the UI flow as suggested by Daniel.

If it is a local list, then you can simply add a condition which checks if the item being iterated in the for each loop, i.e. the current value, satisfies the search query of the user.

Hope this helps!

- Emman

Hi Ali Sapan,

Adding to  Emman's suggestion, I would like to add one more question, Is your search having multiple values (Like list)?


Thanks

Yea it's and aggergate, but do I have to modify it? 


Solution

Hi,

You have to add filters in the aggregate on the inputs on which you want to filter the data.

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Query_Data/Filter_Query_Results

One advice, I have the feeling you just started coding with OutSystems without following any learn track.

OutSystems has very good free learn site https://www.outsystems.com/learn/

The issue at hand would have been clear to you if you would follow the trainings.

Regards,

Daniel

Solution

Alright sorry for that, my fault haha, and thank you very much sir, I'll check it out. 

It kinda worked, but still there are some problems, as you can see when I search for an Item, it only shows one item (with multiple record of the same item, Second Problem). When I search for a different Item, It wont show at all. I think the problem is with my for each loop. 

about the second problem, It happens as well I add the item to my shopping cart, it adds all the items available in the database with multiple records for each item.I've attached my file on here, if someone can help, I'd appreciate it.

I've done it, all I had to do was using the proper parameters in the aggregate to display the correct record and single record entity, I also had to modify to my Search to button to show the aggregate with the condition applied to it. Thank you all for the help!