Search…
Resources
Related Links
createTextFile
To create a text file with a given name and content
With this function, you can create a simple text file (.txt). If not otherwise specified, the file is simply attached to the record (see for the little paperclip
📎
on top, on the right of the tab bar). You can freely choose the file name and the extension.
You can create simple lists or evaluations in text or CSV format for further processing outside of Ninox.
There is no direct formatting possible, but you can add HTML tags, so you could create a simple website with a “.html” extension, which can be read by every common browser.

Syntax

createTextFile(nid, string, string)

Return

file

Examples

We have a database with some records in it. We also have …
  • image field “Image text”
  • rich-text field “Rich text” with content
  • button called “Create my document”
Open the field editor of your button and add the following script to the formula field “On click”.
createTextFile(this, raw('Rich text'), "MyTextFileExample.html")
Save your changes. Click your button “Create my document”. If you don’t define where the new file should be saved (as you do in this example), it will be attached to the record. You’ll find it by clicking on the paper clip
📎
.
'Image text' := createTextFile(this, text('Rich text'), "MyTextFileExample.txt")
Save your changes. Click your button “Create my document” and you should find your TXT file in your image field “Image text”.
Click on the image field and your TXT file will be downloaded. In this text, the file will return the plain text from your text field “Rich text” without any tags.
'Image text' := createTextFile(this, raw('Rich text'), "MyTextFileExample.html")
Save your changes. Click your button “Create my document” and you should find your HTML file in your image field “Image text”.
Click on the image field and your HTML file will be downloaded. This also works with "MyTextFileExample.txt". You’ll then get a simple text file with HTML tags.

See also

file, which returns a specific file based on the file name from a given record.
importFile, which imports a file from an URL and saves it as an attachment of a record.
Export as PDF
Copy link