Hi there,


I´m a newbie, sooo, sorry if I´m asking for help in the wrong place or asking something that has already been answered. Just for the complete info, I have found this thread https://www.outsystems.com/forums/discussion/21854/export-entire-result-of-an-aggregate-to-excel/ but I could not replicate what was offered as an answer. Sorry :(


I have an export to excel button that is working almost flawlessly. It exports the records displayed on the screen. I wish it exported the entire record. Heres the code:


The button "catches"  the result from another preparation. That being said, I can either:


1) Remove de pagination, because it´s a simple application, or

2) Improve the excel export process.


The issue is: I don´t know how to do any of the options.

Below it´s the copy of the preparation, just in case. (please feel free, if you want, of course, to judge, it´s my first application and I´m happy to learn at every chance I can. )

EDIT: I´ve re-uploaded the images.

Hi Rafael,

Don't use the aggregate in the preparation in a Screen Action. It will have negative impact in the page performance.

Instead, just duplicate the aggregate in the Screen Action (a new aggregate) that fetches all the records. If you are not binding it to the Table/List Records in the screen and not setting the Max Records properties, it will return all the records that your aggregate can fetch (depending on joins and filters).

Than use it to export to excel instead.

Hope this helps.

Cheers.

Hi Rafael,

Welcome to the OutSystems community forum!

It seems your images aren't working, but anyways, to export all the data, use the Refresh Data Statement, explicitly specifying a very large number for the Max. Records (say, 1000000000). The Platform will fetch everything then (well, up to that large number, but you can't put that much records in an Excel anyways), which you can export.

HI Maria,

That's just not true. If there's 1000 records in the database, and only 50 on the screen, the list will contain only 51 items. Also, due to view state size, it is a performance best practice to use Refresh Data instead of directly accessing query results from the Preperation.

EDIT: It seems the user I replied to has removed their post. Letting this live for the link to best practices.

Kilian Hekhuis wrote:

Hi Rafael,

Welcome to the OutSystems community forum!

It seems your images aren't working, but anyways, to export all the data, use the Refresh Data Statement, explicitly specifying a very large number for the Max. Records (say, 1000000000). The Platform will fetch everything then (well, up to that large number, but you can't put that much records in an Excel anyways), which you can export.

Hi Kilian,

I´ve tried to upload the images again, now with the refresh data statement, is it in the right place? Because I´ve got still 51 lines. I´ve also tried the refresh before the aggregate with no success too.



Eduardo Jauch wrote:

Hi Rafael,

Don't use the aggregate in the preparation in a Screen Action. It will have negative impact in the page performance.

Instead, just duplicate the aggregate in the Screen Action (a new aggregate) that fetches all the records. If you are not binding it to the Table/List Records in the screen and not setting the Max Records properties, it will return all the records that your aggregate can fetch (depending on joins and filters).

Than use it to export to excel instead.

Hope this helps.

Cheers.

Hi Eduardo,


I didn´t. At least I think so :). I´ve re-uploaded the images, maybe you can check if I did the right thing, totally unintentionally by the way.


Solution

Hi Rafael,

You are using, as source to your RecordListoToExcel, te TABLE RECORDS list.

Use one of the aggregates (the one refreshed or the one you create in the Screen Action).
Try first with the refreshed, as it has the advantage of being exactly the same aggregate you use to show data.

If you need to change it, you will not have the work of changing also the one in the Screen Action.

Cheers.

Solution

Eduardo Jauch wrote:

Hi Rafael,

You are using, as source to your RecordListoToExcel, te TABLE RECORDS list.

Use one of the aggregates (the one refreshed or the one you create in the Screen Action).
Try first with the refreshed, as it has the advantage of being exactly the same aggregate you use to show data.

If you need to change it, you will not have the work of changing also the one in the Screen Action.

Cheers.

Worked like a charm. Thanks @Eduardo Jauch and @Kilian Hekhuis for helping the newbie here !


You're most welcome :). Happy coding!