Issue with file download

I'm trying to debug one of our applications, but (as a beginner), I can't wrap my head around how this works.

Part of the functionality of the app is to export an Excel file with data extracted from a number of entities in the database. For this, we have an export button that triggers a data action that in turn triggers a server action to collect data aggregates and combine these into an excel file.

The flow is as follows:

Export button

  -> OnClick_Export (client action)

    -> GetExportFile (data action)

      -> ExportFile (server action), using mainly aggregates and 'Record List to Excel', returning file and binary data

    Assign ExportFile return to variable

  GetExportFile On After Fetch triggers GetExportFileOnAfterFetch (client action) with some javascript to initiate download.

I assume the javascript is needed since the application was developed as mobile application, meaning we don't have the default download tool that is available in Traditional Web.

The part that I don't understand: the first time the export button is clicked on by the user, the app returns an Excel file that is corrupt (and given the file size is probably empty). The second time the button is clicked, everything works fine and the expected file can be downloaded. Could it be that for some reason the 'On After Fetch' action of 'GetExportFile' is executed before the 'ExportFile' server action is finished? In this case, the second button press would trigger the download of the file that was generated for the first button press.

Hi @Derk de Graaf ,

Can you share a sample OML to see what you are doing wrong?


Luis Oliveira

Fair question, I've attached a sample .oml

In the original project, functionality is split over multiple modules, for the example I've put everything into one.


Using another Forge component is an option, although I'm not sure how that will play with desktop browsers.

Still, I'd like to understand what is happening in our current setup and why it works the second time but not the first, so I better understand the inner workings of Outsystems.

Hello @Derk de Graaf,

I just wanted to add that, the very first file that downloads in the browser (chrome in my case) is an html file and appears to be related to the PWA Manifest. Since the file extension is 'xlsx' so it seems as if it is a corrupted file.



Thanks AJ for verifying the issue. Looking at the code, any idea where this PWA manifest comes from?

Unfortunately not at this point. If time permits I am definitely interested in digging deeper.

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