Check if user is part of aggregate in for each
Application Type
Service

Hi Community,

At this moment I have 2 aggregates. One aggregate (GetUsersWithGroup) retrieves users within a certain group. In the next aggregate I retrieve all users that did nog login for a x amount of time. In the for each I want to check if the current processed user is member of the group. If that is the case the user needs to be skipped and the next user needs to be checked in the for each. Probably this is quite simple but at the moment I can not think of a solution. Can anyone help me into the right direction? Thanks!




The IF, will compare the value from ListFilter. If listfilter returns empty, the user will not be in the group, if not, then the user will be in the group.

Hi Bart,

I think you can merge both aggregate  (don't know what is the aggregate queries for both), But in case is not possible, you can use the listfilter to see if the foreach user is In the other aggregate. 

Hi Luis,

Thanks for your reply. I think it is not possible to join both aggregates because of the queries I am using. For security reasons I am not showing the queries. The check is not possibile with an IF statement only? If not could you please provide an example on how to use listfilter? Not sure what to put in the SourceList, since it seems like I can only put one aggregate list in it. And what should be the condition?

The IF, will compare the value from ListFilter. If listfilter returns empty, the user will not be in the group, if not, then the user will be in the group.

Hi Filipe,

Ah now I get what you mean. Why the listfilter is needed? do I not get the same result if I use the condition from the listfilter in the if statement (like this: GetUsersWithGroup.List.Current.User.Id = GetUsers.List.Current.User.Id)? Sorry if I am asking stupid question, just want to know what I am doing so in the future I do not need to ask these kind of questions anymore :-)

No, because you are using the current and you will only compare to that current value. The only that will change is the foreach value, the other will maintain always the same. That's why you need to use the ListFilter.

If I understand you correctly from the GetUsersWithGroup aggregate comes a list with A, B, C and then I always compare with A, because that is the first result from the aggregate?

I don't really know how to explain it better. You indicate that the value in the for each changes every time. I can follow that, because there are x number of users from the aggregate (for example 10). We then loop through the 10 users and with each loop the value of the user we are currently looping changes.

The value in the other aggregate (GetUsersWithGroup) always remains the same. I am fetching an x number of records (for example 3). Then I always compare the first record from this aggregate in the if with the value in the for each, right?

I did use your example and it works like a charm. Marked your answer as the solution :-)

Nice :), but regarding your previous question, the foreach for example start in the currentrownumber = 0, and it will interate the list till the end, that why the current is always changing for that list. 

Since for the other list, you don't have a foreach (and is not a good practice to use two foreach in this case), you can use the list filter, to filter the other queries to check if the current user is in the other list.

If you compare directly like you did, it will probably always compare to the first or last item of the list (because was not been interated).


Hope that you did understand it now :), if you have some question, please let me know, if I can explain it to you in another way.

Hi Bart,

The list filter action is needed so you can compare the whole list of users with the current record that is being iterated in the for each.

If you don't use the list filter and only an IF-statement, than you will only check the first record of the user table, with the current record that is being iterated.

Hope this helps you a bit.

As an addition. I would advise to use SQl for this matter (IN clause). SO you only have to do one database call, instead of 2 aggregates and an for each.


Thanks for your explanation. It is clear now :-)

I think you are right. Performance wise this would be better.

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