Return unique records between two aggregates

I have two aggregates and I want to get only the unique values between both, how can I do that?


For example, if I have a record with ID = 1 in both aggreagtes, I don't want to show this record at all


Any help?

Hello Mohamed,

Maybe the solution is: Where Table1.Id <> Table2.Id?

Best regards!

Hi Mohamed,

If you can create a relationship between yours tables, create an aggregate with OnlyWith type of join.

Take look at this documentation:

https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Query_Data/Get_Distinct_Values_from_the_Database



Mohamed Emam wrote:

I have two aggregates and I want to get only the unique values between both, how can I do that?


For example, if I have a record with ID = 1 in both aggreagtes, I don't want to show this record at all


Any help?

Hi Mohamed,

Please use way to distinct  a Aggregate just append aggregate to list record and distinct that list record using  DISTINCTRECORDLIST  in  SORTRECORDLIST component. 

https://www.outsystems.com/forge/component-overview/22/sortrecordlist

Hope this will help :)

Best Regards,

Amit Verma

@Amit: In OutSystems 11 there's a ListDistinct Action that does the same. It's better to use that one than the DistinctRecordList, which is a bit difficult to use sometimes.

@Mohamed: You basically don't want that, as it is post-processing of database output in memory. There might be edge cases where this is a good idea, but unless you have a firm grasp of what you're doing, you shouldn't do it. If these two Aggregates are fairly simple, you could try merging them, to prevent the doubles. Alternatively, you could create a SQL query that uses a UNION to do the same. But either way, you probably have code that's not quite suited to your functional need, so perhaps you need to revise the way the data is fetched currently.