Is there a way to export data from a query as a CSV file then be able to download it?

I have a query that I would like to save as a CSV file so that it can be downloaded. I tried using EXPORT TO CSV but nothing happens. Perhaps I’m using the wrong values for the path and export data fields (see image) or maybe that server action is not correct.![pic1|349x456]
(upload://7m81ji62wOEZYlOOvPSlW1FQDht.png)

Once you’ve exported the data to the specified folder, you can create an anchor button to download the file, eg:
image

Thank you, Tom. But my issue is that the CSV file is not being created at all. Do I have the right settings for the export?

pic1

I think the settings look alright. I would first use the Open in Browser button in Server Connect to make sure the query is working. If that’s working as expected, I would look for errors in the browser developer console. Perhaps the folder doesn’t have the correct permissions.

The path must contain the full file path with filename.

Tom,

Can you please tell me exactly where this “open in browser” button is? The expense_summary query is just a simple query with no conditions at the moment so I know there is data. The temp folder has full permissions. That is where I upload my files before I move them to other folders.

Viewing the ouput of a server action is a very useful feature generally. This is the button:

image
(unfortunately I don’t think there’s a shortcut for this)

As far as your problem is concerned, I think @patrick’s reply is the solution. The path needs to be something like:

image
(or the filename can be static)

I will try adding the filename as Patrick suggested. However for the download, I understand what I should put down under the anchor link, but what exactly do I need under the “download” binding? Your example has the parameter name. Is that the name of the file? Isn’t that already in the link? What exactly does the download action do?

In my example, I have a table listing the files in the export folder. Each row has a button to download a file. The values assigned to the button’s dynamic attributes are selected from those made available using the Folder List step in server connect:

image

AWESOME! I got it to work. Thanks for your help!

1 Like