Goal: An eventhandler on a table-row button should trigger a file download
Steps: The function used to work until it suddently stopped working. I'm not aware to have changed something related to that function.
Details:
When the app is freshly loaded the download function fails with the error message data must be a plain object or array in utils.exportData().
When i switch to Edit Mode the function still fails when clicking on the button, but when I click on the Run button of the query the query returns a result.
And the bizarr thing is that from then on the download button in the grid works also and the download starts and completes successfully.
Welcome to Retool! Can you share a screenshot of your actual event handler for that download button? I would have expected to see a call to apiQueryDownload in your first screenshot, so I'm curious as to how that download is set up.
It works in Edit mode because you've manually run apiQueryDownload so there is a value in .data. Because the download action needs to run a query and then download the result, you need to set this up a little differently. Right now you're trying to export the data in that query, but that query never gets triggered. This is what I'd suggest:
Change your event handler to control a query
Pick your query
Choose "trigger" as the method
Under your query, add an onSuccess Event Handler that does the utils.exportData action.