Hi, I have an aggregate that contains records that I want to randomly select. Is it possible to select 2 or more records and display it in a table? How?
Thank you very much.
Hi
From aggregate we access records like yourAggregateList.current.record.attribute. so it will return current record.
If you want to access any other record other than current then can write something below
Youraggregatelist.[current+1].record
So basically you can get records with the reference of current.
Hope it helps.
Regards
As you want random records from aggregate so you can achieve this by current+I in above statement. I can be any random innteger between the length of aggregate.
Hey Dianara,
Let's say you have 2 table you will select records from the first table and display the selected records in the 2nd table.Is this your requirement?
Thanks ,
Sudip Pal
Hi Supid Pal,
No, I only have one table and I plan 2 random data from that table to display it.
Thanks
Please check the above link.
https://www.outsystems.com/forums/discussion/79540/random-item-from-a-list-aggregate/
There is an OML in the above link's discussion use that . Your problem will be resolved without using SQL !!
Thanks,
Hi Dianara,
You can do this more efficiently with a SQL query, like this:
Just replace the parameter @Integer by the actual number of rows that you want to retrieve.
The ORDER BY NEWID() will make sure the records are fetched randomly.
This way you will make sure you only retrieve the records you need instead of retrieving a lot of them and then selecting a subset.
Hope this helps,
Pedro
If you want only 2 records from aggregate then easiest can be take 2 random integer. Can generate random integer by OS random method. Pass these 2 random integers in aggregate filter. Can apply filter on ID of table. As I guess ID is integer type. But ensure range of random integer is between 1 and total no of rows