Hello people,
i have a form that you can fill in. Each time you fill and save it to the DB, it is visible on a table:
So if you fill and save 5 forms to the DB, you will see 5 times your name and your email. However i was wondering how i can do that you ony see 1/first record on the table and when you click on the name it needs to open all the other forms you filled in. This way the table does not get so full. Any ideas?
Hello Samed,
Hope you're doing well.
If you have the result of an Aggregate bound to your TableRecords, you can Group By Name / Email to obtain distinct values.
Please refer to this documentation: https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Query_Data/Get_Distinct_Values_from_the_Database
If your have a List local variable, maybe you can try to use ListDistinct action to filter your duplicate records:
Hope that this helps you!
Edit: I'm assuming that you don't want to see only 1 record, but 1 record per name/email combination (meaning, if you have 2 different names it will appear 2 records).
Kind regards,
Rui Barradas
Hi @Rui Barradas , yes you are right. I want to only see 1 record per name/email. So 2 different names will appear as 2 records. How can i use the ListDistinct function to do this? Do i have to make a action or something?
Can you please show us how you're fetching your list that is bound to the Table Records?
I use Gegevens:
Hi Samed,
You need to use GroupBy on your Name and Email column in aggregate, this will give you the record per unique name .
Thanks
So you're using GetGegevens.List in your Table Records, right? Probably what is happening is that your Aggregate is returning multiple records and it is bound to your table, so all of those records will be displayed (even though you're using only 2 attributes in your Table Records).
There are multiple ways you can do to achieve your purpose.
You can use a Data Action instead of the Aggregate itself:
In this Data Action, you can execute the query, perform your logic (using the ListDistinct) and return the list that you're going to show in the screen.
Your output of the data action can be a List with only 2 fields: Name and Email.
And after you can bind these list to your Table Records:
Let me know if it worked for you.
Hi @Rui Barradas , do you know what this error means?
It means you need to have an Assign for that Output variable. In your scenario, you need to define it as the result of your ListDistinct action.
Hi @Rui Barradas, now i have the following:
but now the table looks like this:
and actually there is only 1 saved data of "piet", but here it has duplicated it so many times?
Can you share your OML so we can take a look on your implementation? :)
@Rui Barradas here you go
Why you not check if record is already in list and give message to user and not save that record.
Thank you Samed.
Now please do me a favor and show me the data present in your Gegevens entity:
The reason I'm asking this is because you seem to have more than one record with the same Name / Email combination, but you use the ID to navigate for AanvraagDetail page for each record:
Do you want to have this navigation?
Hi @Rui Barradas , yes i use that so it is possible to open the record in detail screen. Here is the data
and yes it is possible to have multiple record of the same name/email. But on the UistaandeAanvragen screen i only want to show 1 record of eacht name/email and when you click on a name it needs to open another screen that shows ALL the other records of this name/email
Can you please check if it is what you're looking for?
Hi @Rui Barradas , yes this is it. Now i have to implement that when you click on a name, it shows all the records of this name. This is possible right> And what was wrong with mine implemantation? What do i need to change?
Hi again Samed,
You can check my implementation.
But basically, you can do it directly in the Aggregate and group by name and email like I said in my first post :) because you only use this aggregate to show the result in the screen. Therefore you won't need a data action like I mentioned after. Now you can link it to a new screen where you can show all the records for that name -> you just need to filter your Gegevens entity by the selected name.
To retrieve only one, the most recent, record, sort on date/time of creation (assuming you store it), descending, and set the Max. Records to 1. Then when the user clicks the name, start a Screen Action that refreshes the Aggregate but uses a Max. Records of 0 (which will retrieve all records, iirc).
What are you using to bind the source of this table? Is it Aggregate or Advance SQL Query? If you are using Aggregate try the solution as suggested by @Kilian Hekhuis and if using Advance SQL query use SQL function "Distinct" to fetch the single row from the entity which is having same names and emails addresses.
Thanks & Regards,
Sachin