763
Views
7
Comments
List Filter, For Each
Question


Hi Guys

 I'm having trouble implementing a comparison.


 I have a struct list, which I want to check if it already exists in an aggregatte. example: 

AggregateA 

Struct B list 

Because it's a list, I'm using a for each for the Agregatte and a list filter for the Struct list, but I'm not getting the desired result. I made a drawing, because I can't share the project because it's from the company. 

2022-08-03 04-32-50
Ravi Punjwani

Hi Fabiano,

Your question seem a bit confusing.

Can you explain in a bit more detail what are you trying to achieve in this?

I also want to suggest you that you don't need to use ListFilter only to check if some element with the specified condition exists or not. For that purpose, you can use ListAny which gives a boolean outcome making it easy to decide if the condition satisfies or not. There's another action ListAll which confirms if All the elements in a list satisfy the condition. In your case ListAny seems more appropriate though than ListFilter.

UserImage.jpg
Fabiano Ferreira

In my case I need to check two lists, there will be a record in the database and on a daily basis I will upload new files and these files may have existing files that would need an update to the database or new files for inclusion.

UserImage.jpg
Fabiano Ferreira



And in the case for this check I need to sweep the values of the two lists both the struct and the aggregate 

2023-10-30 09-31-27
Shivam Mishra

Hi

@ fabiano ferreria

You Pass the Wrong List ON ForEach Widget I attached The image Based On the Requirement. please check it.


thanks 

shivam mishra

Screenshot (405).png
2025-04-17 05-42-16
Ajit Kurane

Hi,

In addition to above answers,

You can give try to below forge component or you can refer logic from it.

https://www.outsystems.com/forge/component-overview/14299/list-utilities

Thanks,

Ajit Kurane.

2022-12-09 04-50-17
Shubham Doshi

Hello,

Try with the below logic flow. It will check if the local identifier matches with the aggregate's identifier.

I have uploaded demo oml as well for you to refer.

DemoList.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @fabiano ferreria ,

Go with advice from Ravi, no need for a ListFilter here.

But to help you learn, some more explanation, as I don't think you grasp what ListFilter is.

ListFilter produces a new list besides A and B, containing a copy of the records in B that fit the condition.  

The condition of your Listfilter is wrong for this, it needs to be '=' instead of '<>'.  Now you are producing a list with all records in B that are different from current A, and then the next If will very often be true.

What you want here is produce a list with records in B that fit the current record in A.

So if you fix that, in each iteration of your ForEach, it will either be empty ( record X from aggregate A is not in struct B) or it will have 1 item ( record X from aggregate A is already in struct B, and since your logic will avoid duplicates, only ever once)

The condition of that If might probably work after fixing the condition on the ListFilter, but I would use a check if ListFilter result is empty.

Also, can we ask for the bigger picture here, where does B come from, how come it has more records than those from your aggregate.  Just to check if any of what you are doing here is really neccessary.

Dorine

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