Send Plain Text as File Download
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens
Sends text to the browser as a file, for example a CSV, TXT, HTML or XML file. The text is built from tokens when the action runs. Nothing is saved on the server.
It works in Forms and Listings. It ends the action list, so put it last.
Typical Use Cases
- Let users download a CSV export built with Create CSV from List
- Download a text or XML file generated from form values
- Give users a small HTML or text report they can save
Don't use it to
- Download a file that already exists in the portal. Use Send File for Download instead.
- Keep a copy of the file. Save it with Create CSV from List and redirect to its URL with Redirect to URL instead.
- Return a file from an API. This action only works in Forms and Listings.
Related Actions
| Action Name | Description |
|---|---|
| Create CSV from List | Builds CSV text from a list, which this action can send. |
| Send File for Download | Sends an existing portal file to the user. |
| Redirect to URL | Sends the user to a URL, for example a file's download link. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| File name | The name of the file, for example Orders-[DateTime:Now|yyyyMMdd]. If it's empty, the current page name is used. If it has an extension, for example orders.csv, the extension isn't added again. | Yes | empty string | No |
| File Type | The file type: csv, html, txt, xml or xsl. It sets the content type sent to the browser, and it's added to File name as the extension if the name doesn't have one. | Yes | empty | No |
| Headers | Extra HTTP headers to send with the file. Each row has a Name and a Value, for example Cache-Control and no-store. Content-Type and Content-Disposition are ignored. | Yes | empty | No |
| Force download | When on, the browser downloads the file. When off, the browser may open the file in the current tab instead, if it can show that type. | No | false | No |
| File Content | The text of the file, for example [OrdersCsv]. | Yes | empty string | No |
How the download works
- The action sends a small hidden form to the browser and ends the action list. Any actions after it don't run. In Forms, the submit button is enabled again.
- The browser posts the form, with the file content, to the site.
- The site sends the content back as a file, encoded as UTF-8, with the chosen file name and content type.
With Force download off, the file is sent inline. For types the browser can show, like text or HTML, the browser opens it in the current tab and leaves the page.
Considerations
- Set a File Type. The content type always comes from File Type, even when File name has its own extension. Without one, the file is sent as
application/octet-streamand has no extension unless File name has one. - Turn on Force download unless you want the browser to open the file.
- The content goes through the browser. The text is sent to the browser and posted back, so very large content can hit the site's request size limit.
- The user needs view permission on the module that runs the action.
- Header values can't contain double quotes, since the headers are sent as JSON after tokens are replaced.
- No byte order mark (BOM) is added. Some versions of Excel may show accented characters incorrectly in a CSV without one.
Examples
To understand how to use the below examples, please see Running Examples.
1. Download orders as a CSV file
The first action writes OrdersList as CSV text to the OrdersCsv token. The second action sends that text to the browser as Orders-<date>.csv.
[
{
"Title": "Create CSV from List",
"ActionType": "CSV",
"Description": "Build the CSV text",
"Parameters": {
"EntityName": "OrdersList",
"IncludeAllFields": true,
"RemoveFieldNames": false,
"FieldSeparator": {
"Expression": "",
"Value": "comma",
"IsExpression": false,
"Parameters": {}
},
"StorageLocation": {
"Expression": "",
"Value": "Memory",
"IsExpression": false,
"Parameters": {}
},
"OutputTokenName": "OrdersCsv"
}
},
{
"Title": "Send Plain Text as File Download",
"ActionType": "DowndloadFile",
"Description": "Download the CSV",
"Parameters": {
"FileName": "Orders-[DateTime:Now|yyyyMMdd]",
"FileTypeId": {
"Expression": "",
"Value": "csv",
"IsExpression": false,
"Parameters": {}
},
"Headers": [],
"FileCheck": true,
"DowndloadFile": "[OrdersCsv]"
}
}
]
2. Download a text summary of a form
This action downloads a text file with the values of a contact form, named after the contact.
{
"Title": "Send Plain Text as File Download",
"ActionType": "DowndloadFile",
"Description": "Download contact summary",
"Parameters": {
"FileName": "Contact-[LastName].txt",
"FileTypeId": {
"Expression": "",
"Value": "txt",
"IsExpression": false,
"Parameters": {}
},
"Headers": [
{
"name": "Cache-Control",
"value": "no-store"
}
],
"FileCheck": true,
"DowndloadFile": "Name: [FirstName] [LastName]\nEmail: [Email]\nPhone: [Phone]"
}
}
Revised 09/27/2026