0

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 (look 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 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 File
  • rich-text field Rich text with content
  • button called Create my document

Open the field settings of your button and add the following script to the formula field “On click”.

createTextFile(this, raw('Rich text'), "MyTextFileExample.html")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📎 .

File := createTextFile(this, text('Rich text'), "MyTextFileExample.txt")File := 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 File.

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.

File := createTextFile(this, raw('Rich text'), "MyTextFileExample.html")File := 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 File.

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 a URL and saves it as an attachment of a record.

Reply

null