1259
Views
21
Comments
Solved
How to remove duplicated records ( displayed on screen)?
Question

Hello!

I've got a problem. The records from the database are being displayed on screen. 

they're not duplicated in the database. just when displayed. 


Does anybody know how to solve this?

2012-08-24 04-32-41
Juan Carlos Elorde
Solution

Raissa Domingos wrote:

Juan Carlos Elorde wrote:

Likely a problem in your joins in the aggregate. Can you show what it looks like?

Follow the image of joins. 


You already have a Sector.FunctionalAreaId already. I am just thinking why you also have a cross join for FunctionalAreaXSector. There could just be a wrong relationship on this that is why it duplicates. What you can do is isolate your entities. Meaning, add entities as you need them. 


EFreitas wrote:

Raissa Domingos wrote:

EFreitas wrote:

If you want to show more than one announcements for each sector, you can achieve that by the following:

First create your sectors list.

Second, create an Block that shows the list of annoucements by sector Id.

At the end use that block in the first screen.

the annoucements are being displayed. but the sectors are stil duplicated. Do you think that could be some relationship that is missing or wrong?


You need to remove News entity from the aggregate. You only need to get the Sector list


As EFreitas said, you may need to remove some of the entities you don't need because this may be the cause of the duplicates.


2019-11-01 16-10-49
Nélio Dionisio

Hi 

In the aggregate you can group by one selected attribute, like a primary key (ID), this way you you will get distinct values. But it is important to understand why this is happen, probably some bad join.

I hope it helps :)



2012-08-24 04-32-41
Juan Carlos Elorde

Likely a problem in your joins in the aggregate. Can you show what it looks like?

2019-12-16 17-15-06
Raissa Arantes Menegasse

Juan Carlos Elorde wrote:

Likely a problem in your joins in the aggregate. Can you show what it looks like?

Follow the image of joins. 


2.png
2021-04-08 11-10-22
EFreitas

Is the DepartmentId a SectorId ?

2019-12-16 17-15-06
Raissa Arantes Menegasse

EFreitas wrote:

Is the DepartmentId a SectorId ?


Yes. it is!

2021-04-08 11-10-22
EFreitas

What are the attributes that you want to show in the screen?

Did you already tried the group by solution?

2019-12-16 17-15-06
Raissa Arantes Menegasse

EFreitas wrote:

What are the attributes that you want to show in the screen?

Did you already tried the group by solution?


I wanna show the sectors (in a list) and the annoucements of each sector,  but they're look duplicated.

duplicated.png
2022-09-15 15-26-02
Leonardo Nascimento

Raissa Domingos wrote:

EFreitas wrote:

What are the attributes that you want to show in the screen?

Did you already tried the group by solution?


I wanna show the sectors (in a list) and the annoucements of each sector,  but they're look duplicated.

In this case, i think the solution above is the better to display the elements.

if you prefer, you can work with a list variable with a structure that you need to display in the screen, and at the preparation pass the records to list variable, removing the duplicateds, and use this variable like a source to list widget on the screen.


2025-11-19 06-14-01
Miguel Verdasca
Champion

Hi Raissa,

If I understood your problem, I propose you this solutions:

  • The SortRecordList Extension is your best bet. Use ToObject() around your List.


  • Other solution, the first is to use a single SQL query, using the UNION command, something like:

SELECT ...

UNION

SELECT

Doing this removes the duplicates at the query level, and SQL Server will do the job for you.


  • The other way to remove duplicates is to do use a For Each loop to check if the items in the second SQL Query already exist on the first on one by one, and only append the ones that don't. Note that this will require a For Each loop inside a For Each loop so it not only will look a bit messy, it will also not scale very well.


I hope this help you.

Cheers,

Nuno Verdasca

2022-09-15 15-26-02
Leonardo Nascimento

If you use the group by, int the DepartamentId attribute, may will work well, but which elements you want display in the screen?

2019-12-16 17-15-06
Raissa Arantes Menegasse

Leonardo Nascimento wrote:

If you use the group by, int the DepartamentId attribute, may will work well, but which elements you want display in the screen?

It's not working. When I tried 12 error messages appear, and I don't even know how to solve, cause the logig used  used is not mine, and i'm an outsystems newbie 



2025-11-19 06-14-01
Miguel Verdasca
Champion

Raissa Domingos wrote:

Leonardo Nascimento wrote:

If you use the group by, int the DepartamentId attribute, may will work well, but which elements you want display in the screen?

It's not working. When I tried 12 error messages appear, and I don't even know how to solve, cause the logig used  used is not mine, and i'm an outsystems newbie 



Raissa, try the Distinct function, that I show you. When you pass the list as SourceList, it returns you a list without the duplicates. I think this is what you are looking for.

Cheers,

Nuno Verdasca


2019-12-16 17-15-06
Raissa Arantes Menegasse

Nuno Miguel Verdasca wrote:

Raissa Domingos wrote:

Leonardo Nascimento wrote:

If you use the group by, int the DepartamentId attribute, may will work well, but which elements you want display in the screen?

It's not working. When I tried 12 error messages appear, and I don't even know how to solve, cause the logig used  used is not mine, and i'm an outsystems newbie 



Raissa, try the Distinct function, that I show you. When you pass the list as SourceList, it returns you a list without the duplicates. I think this is what you are looking for.

Cheers,

Nuno Verdasca



I'm gonna try Nuno! Hope it works! Thank you

2022-09-15 15-26-02
Leonardo Nascimento

Raissa Domingos wrote:

Leonardo Nascimento wrote:

If you use the group by, int the DepartamentId attribute, may will work well, but which elements you want display in the screen?

It's not working. When I tried 12 error messages appear, and I don't even know how to solve, cause the logig used  used is not mine, and i'm an outsystems newbie 



Which the attributes you need to display in the screen?

that I show you

2021-04-08 11-10-22
EFreitas

If you want to show more than one announcements for each sector, you can achieve that by the following:

First create your sectors list.

Second, create an Block that shows the list of annoucements by sector Id.

At the end use that block in the first screen.

2019-12-16 17-15-06
Raissa Arantes Menegasse

EFreitas wrote:

If you want to show more than one announcements for each sector, you can achieve that by the following:

First create your sectors list.

Second, create an Block that shows the list of annoucements by sector Id.

At the end use that block in the first screen.

the annoucements are being displayed. but the sectors are stil duplicated. Do you think that could be some relationship that is missing or wrong?


2021-04-08 11-10-22
EFreitas

Raissa Domingos wrote:

EFreitas wrote:

If you want to show more than one announcements for each sector, you can achieve that by the following:

First create your sectors list.

Second, create an Block that shows the list of annoucements by sector Id.

At the end use that block in the first screen.

the annoucements are being displayed. but the sectors are stil duplicated. Do you think that could be some relationship that is missing or wrong?


You need to remove News entity from the aggregate. You only need to get the Sector list


2012-08-24 04-32-41
Juan Carlos Elorde
Solution

Raissa Domingos wrote:

Juan Carlos Elorde wrote:

Likely a problem in your joins in the aggregate. Can you show what it looks like?

Follow the image of joins. 


You already have a Sector.FunctionalAreaId already. I am just thinking why you also have a cross join for FunctionalAreaXSector. There could just be a wrong relationship on this that is why it duplicates. What you can do is isolate your entities. Meaning, add entities as you need them. 


EFreitas wrote:

Raissa Domingos wrote:

EFreitas wrote:

If you want to show more than one announcements for each sector, you can achieve that by the following:

First create your sectors list.

Second, create an Block that shows the list of annoucements by sector Id.

At the end use that block in the first screen.

the annoucements are being displayed. but the sectors are stil duplicated. Do you think that could be some relationship that is missing or wrong?


You need to remove News entity from the aggregate. You only need to get the Sector list


As EFreitas said, you may need to remove some of the entities you don't need because this may be the cause of the duplicates.


2019-12-16 17-15-06
Raissa Arantes Menegasse

Juan Carlos

That cross join for FunctionalAreaXSector. It wasn't made by me. There's other people working on the same module of the aplication. And it's true, that's the cause of the duplicates. Thank you so much for the help!!

2025-11-19 06-14-01
Miguel Verdasca
Champion

You can use this function too:

2025-11-19 06-14-01
Miguel Verdasca
Champion

Before:


After


I had two MIGUEL and one Miguel, and I only had one of each. I know this is a simple example, but it works.

Cheers,
Nuno Verdasca

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