Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
To return the number of full years between now and a given date
Use this function to calculate the current number of full years that have passed since a given date.
The most common application is certainly the calculation of the age of a person based on the date of birth, but other uses are also conceivable:
depreciation periods
special termination rights that might be possible after a certain term (e.g. real estate loan)
determination of anniversaries, etc.
The current date is always used for this calculation.
age(date)
number
Result: Age in years on the current day, starting from the value of the Date of birth field.
Result: 45 (on May 27, 2021)
, which calculates the sine of a number.
To return the arctangent of the quotient
To return the absolute value of a number
The function removes existing signs and returns the absolute, positive value of a number.
It happens rather rarely, but for certain calculations, it may be necessary to continue calculating with the positive value of a possibly negative result. In such cases the function saves querying the value and, if necessary, changing the sign by multiplication.
abs(number)
number
Result: 9.3
, which returns the signum of a number.
To open a pop-up with an alert message
This function will trigger a pop-up with an alert message and an OK button.
You can use this function to display information to the user, which they need to confirm if they want to continue.
If you need to provide options for the user to choose from, we recommend dialog()
.
The function can be executed only on the client. Learn more about
If you call this function more than once within the same script, only the last function call will be executed, so the user has only one box to confirm.
alert(any)
void
Result: Add the code block to a button, and you'll get a popup with an OK button when clicking on it.
Result: This is the time at this very moment: 17:18. (will show the exact time when the popup is triggered.
To create a new array by merging 2 arrays of a similar type
With this function, you can merge 2 arrays of the same data type and create a new array consisting of the values of both arrays.
It might be helpful to merge arrays for evaluation so that you only need to query only 1 array.
If you need to merge more than 2 arrays, just execute the function as often as needed.
array([any], [any])
[any]
array(myArray1, myArray2)
Result: 1,2,3,4,5,6
, which pops up a dialog with answer options.
, which returns a string consisting of all items of the given string array separated by a given separator.
, which extracts a subrange from a string or array.
To capitalize the first letter of each word
This function converts the first character of each word in a text into a capital letter. This can be handy to correct entered data that should always begin with a capital letter, for example, the first and last name of a person.
In Trigger after update, you could add the function to automatically correct the entered data.
capitalize(string)
string
Result: Chamani (with the field Last name = chamani)
Result: Sam Chamani
Result: Dacosta (with the field Last name = dacosta) for example added in the Trigger after update in the field settings of the text field Last name.
lower
, which returns a string in lower case.
upper
, which returns a string in the upper case.
To calculate the arctangent
To return the average value of a number array
Calculate the mathematical average of numeric values from an array or a table with this function.
For example, you can calculate the average revenue per order or the average payment duration of invoices in days, etc.
You can use the function also on table views in columns with numeric values.
avg([number])
number
Result: 5
Result: Average of all invoice totals in the Invoice table.
To convert given time-related values to an appointment
This function helps you to create a from-to-appointment based on 2 timestamps. Instead of the 2nd timestamp, you can also specify a duration and Ninox will return the end timestamp automatically.
If the Start and End timestamp are on the same day, the 2nd won’t be on display. Otherwise, both dates will be displayed, and you should give it enough space to show.
appointment(any, any)
appointment
Your result format may be different depending on your settings.
appointment(start, end)
/ appointment(start, duration)
To convert 2 given time-related values to an appointment.
It doesn't matter if you add the end or the start first, Ninox will automatically select the earliest timestamp as a start.
Result:
03/06/2021 17:00 – 03/16/2021 19:00 (US)
06/03/2021 17:00 – 16/03/2021 19:00 (UK)
Result:
05/22/2021 10:00 - 11:45 (US)
22/05/2021 10:00 - 11:45 (UK)
datetime
, which converts to or returns a timestamp.
To open the barcode scanner and return the scanned value as a string
With this function, you can scan a barcode or QR code via the camera on your mobile device.
To be used only on mobile devices.
Use this function in a button and save the returned value in a text field.
barcodeScan()
string
Add this script in a button.
Result: The camera scans a barcode and adds the value to the text field Item number.
To add content to a temporary file on the Ninox server
This function adds the given content to a temporary file, which will be accessed via a given link created by createTempFile()
.
The respective file must have been created already and still exist when executed.
Use this function in combination with createTempFile()
to render large or long-running exports.
The function can be executed only on the client. Learn more about
appendTempFile(link, string)
appendTempFile(string, string)
void
appendTempFile(myURL, myContent)
To add content to a temporary file on the Ninox server.
Result: First, a temporary CSV file is created on the server and the link to the file is saved in the URL field. Then data from the Customers table will be added line by line to the file.
To evaluate multiple choice fields
The function determines all selected options of a multiple choice field and returns them in an array. You also can query if a specific value is included in the array.
For dynamic multiple choice fields (until now) only the query via the record IDs is possible.
chosen(multi)
chosen(multi, string)
chosen(multi, number)
chosen(dmulit, number)
chosen(multi, [number])
chosen(dmulti, [number])
boolean
[string]
We have a multiple-choice Favorite sports field with the following choice values:
Favorite sport | ID | Selection |
---|
Basketball, Dancing, Sailing, and Soccer are selected.
chosen(myMultiChoice, choiceIdList)
To return Yes (true
) the given numbers representing the choice value IDs are fully covered in the selection.
Result: Yes (true
)
(Sailing is selected, too, but this is not relevant)
chosen(myMultiChoice, choiceId)
To return Yes (true
) if a given number equals the ID of one of the chosen values.
Result: Yes (true
)
(Basketball, Dancing, and Soccer are selected, too, but this is not relevant)
chosen(myMultiChoice, searchString)
To return Yes (true
) if a given string equals at least one of the selected choice values.
Result: Yes (true
)
(Dancing is the relevant selection, the others are not relevant)
Result: No (false
)
chosen(myMultiChoice)
To get all chosen values from a multiple-choice field.
Result: Basketball,Dancing,Sailing,Soccer
Result: Yes (true
) if only Dancing is selected and No (false
) if Dancing is not selected, or also other sports are selected. So No (false
) would be the answer in our example. This helps you to filter these records, where only the given value is selected.
To close fullscreen mode
This function closes the current fullscreen form view.
This function is best used in a button.
closeFullscreen()
void
Add this function in a formula field of a button.
Result: By clicking the button, the fullscreen mode will be closed.
, which opens a given record in fullscreen mode.
, which creates a temporary file on the Ninox server.
, which checks if a given string contains the exact given match.
Basketball | 1 | x |
Climbing | 2 |
Dancing | 3 | x |
Sailing | 4 | x |
Soccer | 5 | x |
To return the currently used language of the browser or app in abbreviated form
This function will help you find out the language a user has set in the respective app. The language is displayed with the corresponding abbreviation, as de for German or en for English.
At Ninox you can set the language individually for each browser or app.
More about the languages supported by Ninox
clientLang()
string
Result: es (if the client has Spanish set as the language)
To close all record forms
This function will close all currently open forms. You will return to the current view of your table.
Use this function for example in a button to speed up the process of closing several form layers stacked on top of each other.
If you'd like to close only the form on top, we recommend closeRecord()
.
closeAllRecords()
void
Result: All open forms are closed and you will return to the current view of your table.
closeRecord
, which closes the top record form.
To round up a given number to the nearest integer
With this function, you can round up a decimal number to the next higher integer. Existing decimal places are removed, and the remaining integer is increased by 1.
If an integer is already passed as a parameter, it remains unchanged.
ceil(number)
number
Result: 3
Result: 13
Result: 27
floor
, which rounds down a given number to the next lower integer.
round
, which rounds a given number to the nearest integer.
To check if a string or an array contains an exact match
This function helps you to check if a given string or array of any length contains the exact match you are looking for.
In case you are not only searching for a specific string or array but also need its position, you can use the index()
function.
The result is true
(Yes) for an exact match or false
(No) for no exact match found.
This is case-sensitive, so you can use upper()
or lower()
to format your text first. contains()
can be used to search for keywords in text fields or to determine if a specific option was selected in a multiple-choice field.
An exact match means the searched value is equal to one of the array items.
contains(string, string)
contains([any], any)
boolean
contains(myText, match)
to check if a given string contains an exact match.
Result: Yes (true
)
Result: No (false
)
Result: Yes (true
)
contains([myArray], match)
to check if a given array contains an exact match.
Result: Yes (true)
Result: No (false
)
JSON objects are not matched by their content but by their identity.
index
, which returns the first position of a searched match in a string or an array.
To close the top record form
This function will close the current form. You will then see either the form below or the current view of your table if there was no other form view open.
The function can be executed only on the client. Learn more about execution context
You could use this function to add an alternative way to close the form. If necessary, you can add further actions.
closeRecord()
void
Result: The current record form will be closed.
openRecord
, which jumps to the related table and opens a given record.
closeAllRecords
, which closes all record forms.
To return all items of an array in one string
This function returns values from an array, a table, or a multiple-choice field one after the other separated by a comma in a text field or a text variable. It’s used to reflect the selected options of a multiple-choice field as a running text, for example in forms or print layouts.
It’s often used for intermediate steps within a script.
concat([any])
string
Result: Böhmer, Frank (with Last name = Böhmer and First name = Frank)
join
, which returns a string of all items of a given string array by a given separator.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our video tutorial.
To create a reminder in the Apple Calendar App
Available on our apps for Mac, iPad, and iPhone. Not on web browsers or Android apps.
Create a reminder in the Apple Reminder App with this function.
createCalendarReminder(string)
createCalendarReminder(string, timestamp)
createCalendarReminder(string, timestamp, timestamp)
createCalendarReminder(string, string, timestamp, timestamp)
void
createCalendarReminder(title)
To create a reminder in the Apple Reminder App with a given title.
createCalendarReminder(title, start)
To create a reminder in the Apple Reminder App with a given title and given start.
createCalendarReminder(title, from, to)
To create a reminder in the Apple Reminder App with a given title, a given start, and end.
To create a text file with specified name, content, and encoding options
The createTextFile
function allows you to create and attach text files directly to records within Ninox. This function supports the creation of various file types, including .txt
, .html
, and .csv
, which can then be downloaded or used outside of Ninox.
You can specify the file's name, extension, and content, and optionally define an encoding format (using the server-side variant). If no specific location is designated, the file will attach directly to the record, accessible via the paperclip icon (📎) in the Attachments tab.
Caution: The encoding
option can only be used within a do as server
code block.
createTextFile(nid, string, string)
createTextFile(nid, string, string, JSON)
record: The record to which the text file will be attached.
content: The text content to be written to the file. This can be:
Text directly entered within quotation marks. For example, "Hello, world!"
.
Text pulled from a text field, multiline text field, or rich text field.
filename: The intended file name, including its extension. For example, file.txt
or document.html
.
options (optional, server-side only): A JSON object specifying encoding options.
encoding: Defines the file's encoding format. Available encoding values:
'utf8'
, 'utf-8'
'utf16le'
, 'utf-16le'
(aliases: 'usc2'
, 'usc-2'
)
'latin1'
(alias: 'binary'
)
'base64'
'base64url'
'hex'
'ascii'
Note: Encoding strings are not case-sensitive. For example, UTF-8 can be specified as utf8
, UTF8
, or uTf8
.
file: A generated file attached to the specified record.
In the following examples, your database contains these fields:
A rich text field named My text containing content to be saved.
An image field named File.
A button named Create document.
To follow these examples, open the settings of the Create document button, then add the corresponding script to the On click formula editor.
To create a text file named MyTextFileExample.txt using the plain text in My text, use:
Explanation:
The text('My text')
function removes any formatting and returns the plain text from My text.
Result:
Upon clicking Create document, a .txt
file named MyTextFileExample.txt is created and attached to the record. You can access the file in the Attachments tab (📎); clicking the image field will automatically download the file.
To create an HTML file (with HTML tags) named MyTextFileExample.html using the text from My text and attach it to the File image field, use:
Explanation:
The raw('My text')
function keeps any HTML tags within My text, allowing the output file to display as a formatted HTML document in a browser.
Result:
Upon clicking Create document, an .html
file named MyTextFileExample.html is created and attached to the File image field. Clicking the image field will automatically download the file.
Note: Using raw('My text')
with an .html
extension ensures that any HTML tags within My text (such as <h1>
, <p>
, etc.) are retained. This allows the file to open in a web browser with structured formatting based on these tags, which is suitable for content you wish to display as a styled web page.
To apply UTF-8 encoding to an HTML file created from My text, use the server-side variant of the function within a do as server
block:
Explanation:
The server-side block (do as server ... end
) is necessary to specify encoding
.
Result:
Upon clicking Create document, an .html
file (encoded in UTF-8) named MyTextFileExample.html is created and attached to the File image field. Clicking the image field will automatically download the file.
Note: The encoding
option is suitable for preserving international characters, special symbols, or multilingual content in the file.
To dynamically create customizable, styled, multi-sheet Excel files directly from databases
With this function, you can create an XLSX file with customizable content and multiple sheets, reflecting the data and style defined in the input parameters.
The resulting file is saved directly in Ninox, offering dynamic data management and formatting options.
createXLSX(nid, any, string)
file
createXLSX
To create an Excel file with the createXLSX
function:
Create a Button field: When clicked, the button triggers a function to create an Excel file from the data provided in the formula editor.
Create an Image field: Serves a link, allowing you to download the file directly.
Enable edit mode and click the On click field. In the formula editor:
Define the columns and rows.
Define the worksheet structure.
Use the createXLSX
function.
Define styles and formatting (optional).
Save the script. Create the Excel file by clicking the button.
First, create an object to define the columns:
Next, define the rows. You can use #special-supported-fields, if you need to:
Define a worksheet with columns and rows:
createXLSX
Call the createXLSX
function with the defined worksheets:
Apply style to a header cell:
Apply style to an entire column except the header:
Apply style to an entire row:
Apply style to specific cells in a row:
Finally, when you've saved your script, click the button to create an Excel file.
thin
dotted
dashDot
hair
dashDotDot
slantDashDot
mediumDashed
mediumDashDotDot
mediumDashDot
medium
double
thick
To fill a cell using the solid
pattern, you don't need to specify bgColor
.
none
solid
darkGray
mediumGray
lightGray
gray125
gray0625
darkHorizontal
darkVertical
darkDown
darkUp
darkGrid
darkTrellis
lightHorizontal
lightVertical
lightDown
lightUp
lightGrid
lightTrellis
The function supports special fields like hyperlinks, rich text, and formulas:
Hyperlinks provide links to web content or internal references.
Rich text allows for mixed-format text, including bold, italic, and other font styles.
Formulas enable cells to compute values dynamically.
Dates can be used directly from Ninox.
To run a given script only once and cache and return the output value
This function allows you to cache calculations of an elaborate script during the first execution. Instead of a new calculation, the saved value is then returned.
But if you want to trigger a recalculation of your script, you have the following options:
Activate the edit mode
Execute the invalidate()
function in any table of your database
This feature can help solve performance problems.
Learn more about Optimizing scripts
cached(script)
any
Result: The records from the Tasks table that are still open and assigned to the current user are cached and returned.
invalidate
, which clears the cache of the database and the values stored by cached()
.
To return or convert to a color value
With this function, you can assign a color value to a color or formula field. You also can get the color value of a selected option in a choice field.
To return a specific color, you can either pass a string referencing the color or 3 (up to 4) numbers referring to the RGB/RGBA colors.
color()
accepts any valid HTML/CSS color identifier.
color(string)
color(number, number, number)
color(number, number, number, number)
color(choice)
color
Result: Blue, but not the Ninox blue.
Result: The Ninox blue
Result: The Ninox blue in RGB code
Result: The Ninox blue in RGB code with the opacity set to 50%
Result: Returns the color of the selected option of the Status choice field.
icon
, which returns an icon.
styled
, which converts a given string to a styled object.
To return the number of concrete items in an array
With this function, you can count the number of entries in arrays or tables that are not null
or empty strings ("").
If you'd like to count all items in your array, we recommend using length()
.
In combination with select ... where
you can count records that meet a specific condition. For example, how many entries have the status open, or how many last names start with a B.
The function can also be very helpful to find out if there are any duplicates in your table.
count([any])
cnt([any])
number
Result: 2
Result: 98
(if the table Invoices contains 98 records, where the Total is greater than USD1,000)
Return: If all IDs are unique, the result is Yes (true
). If there are duplicates, the result is No (false
).
To calculate the cosine
To create a temporary file on the Ninox server
This function creates a temporary file on the Ninox server with the given content and file name and returns a link to that file.
Only members of the respective workspace (team) can access the file via the link.
Use this function in combination with appendTempFile()
rendering large or long-running exports.
This function will only create a file if there is any content in it.
As this file is of temporary nature, it will be automatically deleted at some point. So don't take it for granted.
The function can be executed only on the client. Learn more about .
createTempFile(string, string)
link
createTempFile(myContent, fileName)
To create a temporary file on the Ninox server
Result: The URL field contains a link to the export.csv file.
To create an event in the Apple Calendar App
Available on our apps for Mac, iPad, and iPhone. Not on web browsers or Android apps.
With this function, you can create a direct entry in Apple's calendar app. If no specific calendar is specified, Ninox creates the entry in the default calendar.
createCalendarEvent(string, string, timestamp, timestamp)
createCalendarEvent(string, appointment)
createCalendarEvent(string, timestamp, timestamp)
createCalendarEvent(string, string, appointment)
void
createCalendarEvent(calendar, title, from, to)
To create an event in a given Apple Calendar with a given title and a given start and end.
Result: Creates an entry named "Ninox-Webinar" with the start time from "Start” and the end time calculated from "Duration” in the Apple calendar "Private".
createCalendarEvent(title, appointment)
To create an event in the Apple Calendar App with a given title.
createCalendarEvent(title, from, to)
To create an event in the Apple Calendar App with a given title and a given start and end.
, which creates an event in the Apple Calendar App.
, which returns a specific file based on the file name from a given record.
, which imports a file from a URL and saves it as an attachment of a record.
Font property | Description | Example value(s) |
---|---|---|
horizontal | vertical | wrapText | shrinkToFit | indent | readingOrder | textRotation |
---|---|---|---|---|---|---|
Property | Required | Description |
---|---|---|
Property | Required | Description |
---|---|---|
, which returns the count of all characters in a string or all items in an array.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our .
, which adds content to a temporary file on the Ninox server.
, which creates a reminder in the Apple Reminder App.
name
Specifies the font name.
"Arial" "Calibri" etc.
family
Specifies the font family for fallback as an integer value.
1 - Serif 2 - Sans Serif 3 - Mono Others - unknown
scheme
Specifies the font scheme.
"minor"
"major"
"none"
charset
Specifies the font character set as an integer value.
1 2 etc.
size
Specifies the font size as an integer value.
9 10 12 16
etc.
color
Specifies the font color as an ARGB object.
{ argb: "FFFF0000" }
bold
Specifies whether the font is bold, indicating weight.
true false
italic
Specifies whether the font is italic, indicating slope.
true false
underline
Specifies the font underline style.
true false "none" "single"
"double"
"singleAccounting"
"doubleAccounting"
strike
Specifies whether the font has strikethrough.
true false
outline
Specifies whether the font has an outline.
true false
vertAlign
Specifies the font's vertical alignment.
"superscript" "subscript"
left
top
true
true
integer
rtl
0 to 90
center
middle
false
false
ltr
-1 to -90
right
bottom
vertical
fill
distributed
justify
justify
centerContinuous
distributed
type
Yes
Specifies that this fill uses a pattern.
pattern
Yes
Specifies the type of pattern. See #valid-pattern-types below.
fgColor
No
Specifies the pattern's foreground color.
The default color is black.
bgColor
No
Specifies the pattern's background color.
The default color is white.
type
Yes
Specifies that this fill uses a gradient.
gradient
Yes
Defines the type of gradient, which can be either "angle" or "path."
degree
angle
Indicates the gradient's direction.
A value of 0 places it from left to right.
Values from 1 to 359 rotate the direction clockwise.
center
path
Specifies the relative coordinates for the start of the gradient path.
"Left" and "Top" values range from 0 to 1.
stops
Yes
Specifies the gradient's color sequence.
An array of objects defines the position and color, starting at position 0 and ending at position 1.
Additional positions can specify other colors on the path.
To create a zip archive including all files of a given file array
With this function, you create a zip archive containing all files passed in an array.
At the moment the function works only if it is executed server-side. More about execution context.
createZipFile(nid, [file], string)
file
createZipFile(record, files, filename)
creates a zip archive with all files of the array files
and a given name.
Result: The Products.zip zip archive containing all product photos from the Products table is saved in the File image field.
createTextFile
, which creates a text file with a given name and content.
To return the day of the month from a date value as a number
This function extracts the day of a month from a date, appointment, or timestamp; therefore, the result will be a numeric value between 1 and 31.
You can use all data types containing a date for the calculation.
day(appointment)
day(date)
day(timestamp)
number
day(myAppointment)
To return the day of a given start of an appointment.
day(myDate)
To return the day of the month of a given date.
Result: 1
(with
Date = 07/01/2021) (US)
Date = 01/07/2021 (UK))
day(myTimestamp)
To return the day of the month of a given timestamp.
Result: 20 (of June 20, 2021)
month
, which returns the month from a given date value as a number.
quarter
, which returns the quarter of a given date value as a number.
week
, which returns the calendar week of a given date value.
year
, which returns the year of a given date value.
To convert to or return a date value
This function extracts the date from a timestamp. It also returns a date based on the numeric values for year, month, and day.
If you specify "0" as the value for the day, the last day of the previous month will return. This is a very handy way, to determine the last day of a month.
Furthermore, a Unix time specification in milliseconds can be converted into a date.
date(any)
date(number, number, number)
date
Your result format may be different depending on your settings.
date(year, month, day)
To return a date value.
Result: 07/31/2021 (US) (last day of the previous month)
date(myTimeValue)
To convert a given time-related value to a date value. If the value is a number, it represents the Unix time in milliseconds.
Result: Date from the field Date + Time
Result: Date of the start of the Appointment field
Result: 04/08/2021 (US)
time
, which returns the current time.
To return the duration of an appointment
This function calculates the duration of an appointment for you, i.e. the time between the start and the end. The result is shown in hours and minutes.
If the duration is longer than 24 h, the days are shown additionally. There is no conversion from days to weeks, months, or years.
Summer and winter time are considered.
duration(appointment)
timeinterval
Your result format may be different depending on your settings.
Result: 4 Days 9:00 (with holiday1: 05/24/2021 09:00 - 05/28/2021 18:00 (US))
Result: 2 Days
, which converts given time-related values to an appointment.
To convert an angle from radians to degrees
To convert a given value to an email value
This function converts a regular formula field to an email field with a mailto button.
Click the button to open your local email clients and send an email.
There is no sanity check of the transferred content. Every given string will be displayed as an email field.
email(any)
email(myEmail)
Result: steve.rogers@theavengers.com
(as an email field with a little envelope you can click that directly links to your default email client)
, which converts a string or a number to a phone value.
To extract a string from a given text using a regular expression
With this function, you can extract the first match of a search string in a text.
Instead of simple strings as a search pattern, you can use regular expressions (regex). That means you have much more possibilities for text analysis.
You could use this function for example to extract relevant information from imported data.
Using regular expressions might need some extra research. We recommend checking regular expressions on https://regex101.com/ (external link).
extractx(string, string)
extractx(string, string, string)
extractx(string, string, string, string)
string
extractx(myText, regex, flags, extract)
To extract a string from a given text using a regular expression. Flags can be added to the regular expression. The string can be further processed with a given extract.
We have a database with some records in it. We also have …
an image field My attachment with a file ImportantDocument.pdf
a formula field File name
Open the field settings of your formula field File name and add the following script to the formula field Formula:
Result: In the formula field you will see the name of the attachment: ImportantDocuement.pdf
extractx(myText, regex, extract)
To extract a string from a given text using a regular expression. The string can be further processed with the given extract.
extractx(myText,regex)
To extract a string from a given text using a regular expression.
replacex
, which replaces matches of a given regular expression.
substr
, which returns a new string out of a given text.
testx
, which returns true
if a given text matches a given regular expression.
To return a specific file based on the file name from a given record
With this function, you can address a specific file attachment of a record, e.g. to display it in an image field or to send it as an attachment of an automatically generated e-mail.
file(nid, string)
file
file(record, fileName)
To return a specific file based on the file name from a given record.
Result: Returns the file “RE-2021_13874.pdf” from the current record.
files
, which returns all attachments of a record as an array.
importFile
, which imports a file from a URL and saves it as an attachment of a record.
To calculate the natural exponential function
The function calculates the exponential function of a number based on Euler's number and is therefore called the natural exponential function.
exp(number)
number
exp(x)
To calculate the power to the base e (e is the Euler's number) with a number x as an exponent.
Result: 2.718281828459045 (the Euler’s number)
Result: 1
Result: 20.085536923187668
ln
, which calculates the natural logarithm of a number.
To pop up a dialog with answer options
This function will trigger a pop-up with notes created by you. You can add a selection of options with answers to choose from, for example, Yes or No.
The running script is put on hold until the user picked an answer.
The result can be stored in a field or variable and therefore be processed in the further execution of the script.
The function can be executed only on the client. Learn more about execution context
dialog(string, string, [string])
string
dialog(title, message, answerOptions)
To pop up a dialog with answer options.
Add this script to a button.
Result: You should get this popup. By clicking Yes this record will be deleted.
alert
, which opens a pop-up message box.
To return the ID of a field
This function retrieves the internal identifier of a specified field. A field represents a location stored within a row of a table in a database. Each field is defined by an ID, a name, and a field type. Field IDs are capital letters starting with "A," "B," ..., "AA," "AB," etc.
fieldId(nid, string)
fieldId(string, string)
string
fieldId
No direct UI references in scripts: This function allows you to work with field IDs rather than field names, so your scripts aren't tied to specific UI elements. This is helpful if field names change over time.
fieldId
Calculations without the field name: You can use fieldId
to do calculations or work with data without needing to know the exact field name, making your scripts more flexible.
Populate a row with JSON objects: You can use fieldId
to easily fill a row with data from JSON objects, making data entry and management simpler.
Use fieldId(nid, fieldName)
to retrieve the field ID using the current table's record ID (nid
) and the field name:
Result: D
This is the field ID for the field named "Name" in the current table.
Use fieldId(tableName, fieldName)
to retrieve the field ID using the table name and field name:
Result: A
This is the field ID for the field named "Name" in the "Customer" table.
Use fieldId(fieldName)
to retrieve the field ID using the field name:
Return: D
The field ID for the field named "Number" in the current table.
tableId
which returns the ID of a table.
databaseId
which returns the ID of a database.
teamId
which returns the ID of the current workspace.
To return "true" if the number is even
With this function, you can check whether a number is even, i.e. divisible by 2 without remainder. The return value is either Yes (true
) or No (false
). The 0 is also evaluated as even.
even(number)
boolean
Result: Yes (true
)
Result: No (false
)
Result: Yes (true
)
Result: No (false
)
odd
, which returns Yes (true
) if the number is odd.
To return all attachments of a record as an array
In contrast to file()
with this function, you can address all file attachments of a record, e.g. to send them as an attachment of an automatically generated e-mail or search for specific files in a table.
files(nid)
[file]
Return: An array with all attachments of the current record.
Return: 10 (If the current record has 10 attachments).
You (Steve Rogers) would like to send an email with the attachments of the current record to Hulk. This would be the script in the button within the record, that Steve would click to trigger the action.
Result: Hulk will receive an email with all the attachments of the current record.
To return the metadata, like file name, size and modification date of a file based on a given record and file name
With this function, you can find out the metadata of a file. You will get back:
file name
file size
modification date
fileMetadata(nid, string)
JSON
fileMetadata(record, fileName)
To return the metadata, like file name, size and modification date of a file based on a given record and file name.
Result:
{"name":"Invoice_001.pdf","size":95935,"modifiedDate":1661385600000}
Result:
{"name":"Invoice_001.pdf","size":95935,"modifiedDate":1661385600000}
with the file name pulled from the Invoice image field.
, which returns a specific file based on the file name from a given record.
, which imports a file from a URL and saves it as an attachment of a record.
, which extracts a value of an array or an object.
To create a duplicate of a given record
With this function, you create an exact duplicate of the record to which you apply this function. Also, linked data from sub-tables will be transferred.
duplicate(nid)
nid
Result: The current record—with all entries—is duplicated.
Result: Creates a duplicate of the current record and opens it.
To return a value of a given field
This function retrieves the value of a field. You can use get
to access fields by their name or ID, making it easy to extract data for use in scripts and calculations.
get(nid, string)
text
number
boolean
void
get
Easy to use: It makes it easy to get data from fields in a consistent way, no matter what type of data it is.
Integration: You can easily use get
with other functions like set to update and manage data dynamically in your scripts.
More flexibility: The get
function can fetch data using either the field's name or ID, making it easy to work with different field naming styles and database setups.
Using get
can make it easier to access and work with data in Ninox, allowing for efficient data management and easy integration with other functions.
Here are some simple examples to show how the function works with different inputs.
Return: Vania
Return: true
Return: 42
Return: void
In a typical scenario, in checklist forms field names are often numbered. For example:
Object name 1, Value 1, Date 1
Object name 2, Value 2, Date 2
Object name 3, Value 3, Date 3
To collect all this data and place it into a subtable, you might traditionally use:
The traditional method requires you to specify each object individually. As the number of objects increases, your script grows and becomes more complex. With get
and set, your script stays concise and manageable, regardless of how many objects you have.
get
and set
The get
and set functions simplify this process. get
pulls the value from the main record by building the field name dynamically based on the current index. Then, set pulls that value into the matching field in the new subtable record. Here's how you can use it:
set
which updates the value of a given field.
To return a rich text representation of any value
With this function, you can display text that contains HTML tags. You can use all basic HTML tags for display, but also tables, lists, and inline styles.
The result can be displayed in a formula field, for example, or be used together with sendEmail()
.
In a normal text field, any HTML tags will not be interpreted but simply displayed as text.
In a Rich text field, the text will be formatted according to the HTML tags.
html(any)
html
Result: Ninox is great!
Result: Ninox is great! in a red box with the size (100px x 100px) in a Rich text field.
To return the first item of an array
You can access the first entry of an array with this function. This function comes in handy if you try to access a record in an array of records.
The record IDs of the tables are arranged differently in the multiple platforms. Therefore, different results are displayed according to each platform. This applies if the array consists of records.
If you combine the function with select
and the respective array has more than 1 element, we recommend sorting the array first with order by
.
first([any])
any
Result: B
Result: Returns the first record of the Customer table.
Result: Returns the first record of the table Customer where the last name starts with an A.
, which returns the last item of an array.
, which extracts a value of an array or an object.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our .
To convert a given JSON object into XML text, which might be optically structured
Use this function to convert data into XML format. XML is beside JSON one of the most popular formats for exchanging data. That's why this function is of particular interest when connecting to external servers via API.
More about API at Ninox.
formatXML(JSON)
formatXML(JSON, boolean)
string
formatXML(JSON)
To convert a given JSON object into XML text.
formatXML(json,pretty)
To convert a given JSON object into XML text. If pretty
is true
the text is optically structured.
Result: You'll get an XML string with the data from the JSON object.
parseXML
, which converts an XML string to a JSON object.
To import a file from a URL and save it as an attachment of a record
With this function, you can import a file and attach it to a record or insert it in an image field.
The file can be pulled/retrieved from an external URL. But with printAndSaveRecord()
you can also attach an extra created file.
importFile(nid, string)
importFile(nid, link)
importFile(nid, string, string)
importFile(nid, link, string)
file
importFile(record, link, fileName
) To import a file from a given URL string and save it as an attachment of a record.
Result: The file provided via the given link is attached to the current record with the name Image.jpg.
Result: Prints the current record in the Invoice layout to a PDF and saves the file in the Invoice image field.
printAndSaveRecord
, which saves a given record in a given layout as a PDF in the internal file system and returns a link to the file.
file
, which returns a specific file based on the file name from a given record.
files
, which returns all attachments of a record as an array.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our video tutorial.
To format a given value
With the function, you can format numbers, date, and time values as you need them, to use them in text or formula fields.
Note: Format numbers
All entries are optional. If you do not specify anything, nothing will be formatted.
If you want to format numbers with this function, you must specify the defaults for formatting in a certain order:
First, specify whether a prefix should be inserted, e.g. a currency symbol.
Should a 1000 separator be inserted?
Specify whether or how many decimal places you want to display.
Specify a unit, e.g. a currency sign.
Type of decimal place separator, e.g. period (.
), comma (,
), single quote ('
) or double quotes ("
).
Type of 1000 separator, e.g. period (.
), comma (,
), single quotation mark ('
), double quotation marks ("
) or a space (
).
Use double quotes (""
) for quotes within a string.
format(number, string)
format(date, string)
format(date, string, string)
format(appointment, string)
format(appointment, string, string)
format(timestamp, string)
format(timestamp, string, string)
format(time, string)
string
Your result format may be different depending on your settings.
format(myNumber, formatExpression)
To format a given number as a string.
Result: 2.385,97 €
Ergebnis: $2,385.97US
Result: 0000012345
format(myDate, formatExpression)
To format a given date as a string.
Result:
Mon, May 31, 2021 (with “Date” = 05/31/2021) ((US)
Mon, 31st May 2021 (with “Date” = 31/05/2021) (UK)
format(myDate, formatExpression, language)
To format a given date as a string, where the result shows in a specific language supported by Ninox.
format(myDatetime, formatExpression)
To format a given timestamp as a string.
Result: 1622466387 (on May 31, 2021 15:06)
"X" shows the result without Milliseconds! "x" shows the result with Milliseconds.
format(myAppointment, formatExpression)
To format a given start of an appointment as a string.
format(myAppointment, formatExpression, language)
To format a given start of an appointment as a string, where the result shows in a specific language supported by Ninox.
format(myTime, formatExpression)
To format a given time as a string.
format(myDatetime, formatExpression, language)
To format a given timestamp as a string, where the result shows in a specific language supported by Ninox.
To send an HTTP request
With this function, you can make an API call to access data outside your current database. You can integrate some external services or exchange data between 2 databases.
This function can take up to 4 parameters:
Method
A string defining the HTTP method for the API call. This is usually "GET"
, "POST"
, "PUT"
, or"DELETE"
URL A string holding the URL to the external service
Header An optional JSON object containing meta information of the API call like an API key or the content type.
Body An optional JSON object usually containing the data that will be shared with other external services.
Using API might need some extra knowledge.
To access a Ninox database you need an API key.
We recommend executing this function together with do as server
. More about
http(string, string)
http(string, string, JSON)
http(string, string, JSON, JSON)
http(string, string, JSON, [file])
http(string, string, JSON, JSON, [file])
JSON
http(method, url)
To call REST services without a header or body.
http(method, url, header)
To call REST services—the method and URL are strings; the (optional) header is a JSON object.
http(method, url, header, body)
To call REST services—the method and URL are strings (header and body are optional objects).
Result: You will receive a JSON object either containing all tables of the database if the API call is successful, or a JSON object containing an error message if not.
Result: You will receive a JSON object either containing all records of the Customers table, where the Status = 4, if the API call is successful or a JSON object containing an error message if not.
http(method, url, header, files)
To call REST services and include a list of files - the method and URL are strings; the (optional) header is a JSON object.
http(method, url, header, body files)
To call REST services and include a list of files - the method and URL are strings (header and body are optional objects).
Expected result | Formula |
---|
More information about our.
More about
238597 |
|
238597,00 |
|
2387,970 |
|
$2,385.97US |
|
2.385,97 € |
|
To create a JSON string of a valid JSON object
This function converts a JSON object to a string. This can be useful if you want to check the content of an incoming JSON object or if you want to modify it with other text functions.
formatJSON(JSON)
string
With this script inserted in a button, you can store the response of an API GET request in the field Text to check the response object. Without formatJSON()
the result would not be very helpful.
More about API at Ninox.
Please remember to exchange the following API key with your personal API key.
Result: You'll get a JSON string with data of your current table:
{"result":{"id":"I","name":"Table1","fields":[{"id":"A","name":"Text","type":"string"},{"id":"B","name":"Number","type":"number"},{"id":"D","name":"Text 2","type":"string"}]}}
parseJSON
, which converts a JSON string to a JSON object.
text
, which converts a value to a string and possibly reflects the format options.
To clear the cache of the database and the values stored by cached()
If you execute this function in any table of your database, all values in the database cache (e.g. via cached()
) will be deleted.
This causes the cached()
function to re-execute the script it contains on the next computation.
invalidate()
void
Result: The database cache is empty.
cached
, which runs a given script only once and caches and returns the output value.
To return a string consisting of all items of the given string array separated by a given separator.
Merge multiple elements from an array or table into one string.
Unlike the function concat()
, however, you can specify here which character should separate the elements. This can be a comma, for example, but also a line break. If you select a line break, you can output the entries in a multiline text field.
The function has nothing in common with the SQL statement of the same name.
join([string], string)
string
join(stringArray, separator)
To return a string consisting of all items of the given string array separated by a given separator. The separator can be a line break.
Result: A B C
Result: The names of all customers whose sales are higher than €10,000, one after the other, separated by commas.
concat
, which returns all items of an array in one string.
To return the latitude value of a given location value
This function will extract the latitude of an address in a location field as a decimal number.
latitude(location)
number
Result: 52,5235175 (for Monbijouplatz 5, 10178 Berlin—Ninox office address)
location
, which returns a location value with a given title, latitude, and longitude.
longitude
, which returns the longitude of a given location.
To return Yes (true) if a password is needed to enable edit mode
Check if enabling edit mode in a database requires a password.
isDatabaseProtected()
boolean
Result: Yes (true
) if the database is protected by a password
Add the above script in a formula field and you'll get the following result.
Result: The edit mode requires a password! (if the edit mode in a database is password protected)
isDatabaseLocked
, which returns Yes (true
) if the database is locked.
To return the last item of an array
You can access the last entry of an array with this function. This function comes in handy if you try to access a record in an array of records.
The record IDs of the tables are arranged differently in the multiple platforms. Therefore, different results are displayed according to each platform. This applies if the array consists of records.
If you combine the function with select
and the respective array has more than 1 element, we recommend sorting the array first with order by
.
last([any])
any
Result: C
Result: Returns the last record of the table Customer.
Result: Returns the last record of the table Customer where the last name starts with an A.
first
, which returns the first item of an array.
item
, which extracts a value of an array or an object.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our video tutorial.
To return Yes (true) if the database is locked
This function helps you find if the edit mode needs a password to be enabled and if it is already entered... or not.
If the function returns No (false
), the password was already entered, or if the database is not password protected.
isDatabaseLocked()
boolean
Result: No (false
) if the database is not protected by a password or if the admin entered the password already
Add the above script in a formula field and you'll get the following result.
Result:
(if the edit mode in a database is password protected and the password wasn't entered yet)
isDatabaseProtected
, which returns Yes (true
) if the database is protected by a password.
To round down a given number to the nearest integer
To return the count of all characters in a string or all items in an array
This function returns the number of characters (with spaces) of a given text or the number of items in a given array.
You can use this function for calculations with the size of an array, compare strings, or check if fields contain a certain number of characters.
Together with the functions substr()
or index()
, this function could also help you to return the number of characters from a specific starting point.
length(string)
length([any])
number
Result: 15
Result: 5
To calculate the natural logarithm
The function returns the logarithm to base e (the Euler’s number) and is therefore called the natural logarithm.
It returns a positive number. In the case of 0, the result is -∞ (minus infinity).
ln(number)
number
ln(x)
To calculate the natural logarithm of a number x to the base e (e is the Euler’s number).
Result: 0
Result: -∞
Result: 4.605170185988092
, which rounds up a given number to the next higher integer.
, which rounds a given number to the nearest integer.
, which returns the number of concrete items in an array.
, which returns the first position of appearance of the match in the string.
, which returns a substring out of a given text.
, which converts a value to a string and possibly reflects the format options.
, which calculates the natural exponential function.
To extract a value of an array or an object
With this function, you can access a specific element in an array or JSON object based on a given index or key.
The index of the first element in an array is 0, the second element is 1, etc.
A key in a JSON object might be a string or a number.
item([any], number)
item(JSON, number)
item(JSON, string)
any
item(myArray, choice)
To extract a single item of an array, where the index is zero-based.
Result: Cucumber
Result: Ninox Software GmbH with the comma (,) being the separator and 0 for the first entry. 1 would return Monbijouplatz 5.
item(myJSON, key)
To extract the value of a key-value pair of a given JSON object. The key might be a string or a number.
Result: Steve
first
, which returns the first item of an array.
last
, which returns the last item of an array.
To convert to or return a local timestamp
You can use this function to create a timestamp from a date and time or numeric values. If the parameter for the time is missing, it will automatically use 00:00.
datetime(number)
datetime(number, number, number)
datetime(number, number, number, number)
datetime(number, number, number, number, number)
datetime(number, number, number, number, number, number)
timestamp
Your result format may be different depending on your settings.
datetime(year, month, day)
To return a timestamp out of the given year, month, and day numbers.
Result: 05/27/2021 00:00 (the time is set automatically) (US)
datetime(year, month, day, hour)
To return a timestamp out of the given year, month, day, and hour numbers.
datetime(year, month, day, hour, minute)
To return a timestamp out of the given year, month, day, hour, and minute numbers.
Result: 05/27/2021 18:05 (US) 27.05.2021 18:05
datetime(year, month, day, hour, minute, second)
To return a timestamp out of the given year, month, day, hour, minute, and second numbers.
datetime(year, month, day, hour, minute, second, millis)
To return a timestamp out of the given year, month, day, hour, minute, second, and millisecond numbers.
datetime(myDate, myTime)
To convert a given date and a time to a timestamp.
Result: The date of the field Date and the time of the field Time, for example, 05/27/2021 18:05.
datetime(millis)
To convert a given number to a timestamp where the number represents the Unix time in milliseconds.
date
, which converts to or returns a date value.
time
, which returns the current time.
format
, which formats a given value.
To return an icon
With this function, you can assign an icon value to an icon or formula field. You also can get the icon value of a selected option in a choice field.
Currently, there are 254 icons available at Ninox. Each icon has an internal name to refer to.
icon(choice)
icon(string)
icon
Result: The icon of the selection of the choice field.
Result:
To fill up a given length with given padding at the beginning
With this function, you fill a text at the beginning, i.e. to the left of the text, with one or more given characters up to the desired total length. The given characters are repeated until the given total length is reached.
This can be very useful when - for technical reasons - data must have a certain length, or for optical padding in print layouts in a non-proportional font.
If the source text already reaches or exceeds the specified length, it remains unchanged.
lpad(string, number, string)
string
lpad(myText, length, padding)
To fill up a given length with given padding at the beginning, if the given text is shorter than the given length.
Result: + + + + + + + A text
Result: 00000123
To return the end timestamp of a given appointment
The function returns the end timestamp of a given appointment. The result is a value with date and time, which can be further processed or formatted.
endof(appointement)
timestamp
Your result format may be different depending on your settings.
Result:
07/03/2021 06:00 PM (US)
03/06/2021 18:00 (UK)
(with Appointment =
06/02/2021 09:00 AM - 07/03/2021 06:00 PM (US)
02/06/2021 09:00 - 03/07/2021 18:00 (UK))
Result: Friday, 18:00 h
(with holiday1 =
05/24/2021 09:00 AM - 05/28/2021 06:00 PM (US)
24/05/2021 09:00 - 28/05/2021 18:00 (UK))
To return the number of days between 2 dates
With this function, you calculate the number of days between 2 date values. All days of the week count, i.e. Monday until Sunday. All data types that contain a date can be used.
The function is handy to determine and check deadlines, periods, and due dates.
days(date, date)
number
days(start, end)
To return the number of days between 2 given dates.
date1 = 07/02/2021 and date2 = 12/31/2021 (US)
Result: 183 (days until New Year’s Eve)
, which returns the number of workdays (Monday – Friday) between 2 dates.
To return the start position of the first match in a string or an array
With this function, you can determine the position of a searched value within a given string or an array.
Unlike contains()
, this function not only checks whether the searched value exists but also determines the numeric value of its start position within a string or an array. Counting starts at 0.
If there is no match for the searched value, the result is -1.
If the searched value is part of a string, the position of the match's first characters is returned. The result is then 0.
If you don't want to distinguish between upper and lower case letters, we recommend that you unify either the specified text or the searched string with the functions or .
If there is no array item that is identical to the searched value, the result is -1.
index(string, string)
index([any], any)
number
index(string, match)
determines the first position of a given match in a string, starting with 0.
Result: 3
Result: 0
Result: -1 (no exact match found)
index([myArray], match)
determines the first position of a given match in an array, starting with 0.
Result: 2
Result: 2
Result: -1 (no exact match found)
To return the longitude of a given location value
This function will extract the longitude of an address in a location field as a decimal number.
longitude(location)
number
Result: 13,3989201 (for Monbijouplatz 5, 10178 Berlin—Ninox office address)
, which returns the latitude value of a given location field.
, which returns a location value with a given title, latitude, and longitude.
To convert a file to URL-compliant base64 format
This function converts a file into a URL-compliant string. You can then use this in a REST API call, for example.
loadFileAsBase64URL(file)
loadFileAsBase64URL(nid, string)
string
loadFileAsBase64(record, fileName)
To convert a given file from the attachment of a record to a base64URL format.
Ergebnis: data:image/gif;base64,R0lGODlhgACAAPYpAPDNPv///+fBL/L1+Nff6qp9HLWvhvj5+/n7/MKoYNGtQ5urunRTJey4Jfv8/f39/t/l7qmVZe3w9 ...
(a base64URL string was generated from the file "myPhoto.jpg" from the attachment of the current record)
loadFileAsBase64(datei)
To convert a given file to a base64URL format.
Ergebnis: data:image/gif;base64,R0lGODlhgACAAPYpAPDNPv///+fBL/L1+Nff6qp9HLWvhvj5+/n7/MKoYNGtQ5urunRTJey4Jfv8/f39/t/l7qmVZe3w9 ...
(a base64URL string was generated from the file in the image field Photo)
To output a string in lowercase
This function converts uppercase characters in a text to lowercase. Other characters stay untouched.
This can be useful for comparing strings or for correcting misspellings, for example in names, labels, or for temporarily unifying text for further processing.
lower(string)
string
Result: lower
Result: Yes (true
)
, which returns a string in uppercase.
To converts a file to base64 format
This function converts a file into a string. You can then use this in a REST API call, for example.
loadFileAsBase64(file)
loadFileAsBase64(nid, string)
string
loadFileAsBase64(record, fileName)
To convert a given file from a record's attachment to base64 format.
Result: R0lGODlhgACAAPYpAPDNPv///+fBL/L1+Nff6qp9HLWvhvj5+/n7/MKoYNGtQ5urunRTJey4Jfv8/f39/t/l7qmVZe3w9O67J5acotfFjM+PFKy90+SmG+qyIvDAKY+PjbbI3Obs8vHz9vjRL/b4+tCrL7uaKsaUH9mhI4B+e+etH8LR4PfNLufIVaCzzAAAAERERB8fHzwpEfDAJvXQTOTi3/reZnxpUsDAv/z8/ ...
(a base64 string was generated from the file "meinFoto.jpg" from the attachment of the current record)
loadFileAsBase64(datei)
To convert a given file to base64 format.
Ergebnis: R0lGODlhgACAAPYpAPDNPv///+fBL/L1+Nff6qp9HLWvhvj5+/n7/MKoYNGtQ5urunRTJey4Jfv8/f39/t/l7qmVZe3w9O67J5acotfFjM+PFKy90+SmG+qyIvDAKY+PjbbI3Obs8vHz9vjRL/b4+tCrL7uaKsaUH9mhI4B+e+etH8LR4PfNLufIVaCzzAAAAERERB8fHzwpEfDAJvXQTOTi3/reZnxpUsDAv/z8/ ...
(a base64 string was generated from the file in the image field Photo)
, which converts a given string to a styled object.
, which fills up a given length with given padding at the end.
, which returns the start timestamp of an appointment.
, which checks if a given string or array contains the exact given match.
, which converts a file to base64 format.
, which returns an URL of a specific file.
, which converts a file to URL-compliant base64 format.
loadFileAsBase64
shareFile
loadFileAsBasedURL
To calculate the logarithm
The function returns the logarithm of a number to a base. If no parameter is specified for the base, it is 10. In the case of 0, the result is -∞ (minus infinity).
log(number)
log(number, number)
number
log(x,y)
To calculate the logarithm of a number x to the base of a number y.
log(x)
To calculate the logarithm of a number x to the base of 10.
Result: 0
Result: -∞
Result: 0.6826061944859853
To return the full month name of a given date value
This function will display the month’s name. This might be helpful if you want to group dates within a year by month.
monthName(date)
monthName(date, string)
monthName(number)
monthName(number, string)
string
monthName(myDate)
To return the full month name of a given date.
monthName(myDate, language)
To return the full month name of a given date in a specific language supported by Ninox.
Result: Juillet
monthName(monthNumber)
To return the full month name of a given month number with 1 = January, 2 = February, … 12 = December.
Result: July
monthName(monthNumber, language)
To return the full month name of a given month number in a specific language supported by Ninox.
weekdayName
, which returns the full weekday name of a given date value.
To return the highest or latest value of an array
Use this function to find the highest value or the latest value in an array.
The function works only with an array of numbers or time-related values.
max([any])
max([number])
max([timestamp])
any
max([number)]
To return the highest number of a number array.
Result: 35
max([date])
To return the latest timestamp of a timestamp array.
Result: The last birthday of a year (for example of an employee)
min
, which returns the lowest or earliest value of an array.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our video tutorial.
To return a given month as a number out of a string
With this function you extract the number of the month from a string, for example, March will be 3.
This is helpful if the month is only available as a string, i.e. the name of the month, but you need it as a number for further calculation.
Ninox recognizes always the preset language.
monthIndex(string)
number
Result: 7
weekdayIndex
, which returns a given weekday name as a number.
To return the current timestamp
This function gives you the exact date and time from the exact moment when the function is executed. You are creating an exact timestamp.
This can be very helpful when calculating periods or durations, which are based on date and time values.
now()
timestamp
Your result format may be different depending on your settings.
Result:
06/02/2021 04:45 PM (US)
02/06/2021 16:45 (UK)
(for example on June 2nd, 2021 at 16:45)
Result:
06/09/2021 (US)
09/06/2021 (UK)
(for example on June 2nd, 2021 at 16:45)
today
, which returns the current date without time.
To return the lowest or earliest value of an array
Use this function to find the lowest value or the earliest value in an array.
The function works only with an array of numbers or time-related values.
min([any])
min([number])
min([timestamp])
any
min([number])
To return the lowest number of a number array.
Result: 1
min([date])
To return the earliest date of a date array.
Result: The first birthday of a year (for example of an employee)
To return the month from a date value as a number
Use this function to return the month from a date value. This will be a number between 1 and 12, with January = 1, February = 2, … December = 12.
month(date)
month(appointment)
month(timestamp)
number
month(myDate)
To return the month of a given date as a number.
Result: 5 (on May 31, 2021)
Result: 8 (on May 31, 2021)
month(myAppointment)
To return the month of the start date of a given appointment as a number.
month(datetime)
To return the month of a given timestamp as a number.
, which returns the highest or latest value of an array.
Do you want to dive deeper into the topic? Take a look at the corresponding part of our .
, which converts to or returns a date value.
, which returns the day of the month from a given date value as a number.
, which returns the quarter of a given date value as a number.
, which returns the calendar week of a given date value.
, which returns the year of a given date value.
To return a location value with a given title, latitude, and longitude
This function returns a location value based on a given latitude and longitude, which can have a random title. This information can be stored in a location field.
location(string, number, number)
location
location(title, latitude, longitude)
To return a location value with a given title, latitude, and longitude.
Result: Stores the location with the given coordinates in the Address location field.
latitude
, which returns the latitude value of a given location field.
longitude
, which returns the longitude of a given location.
To identify the type of environment that is currently being used
This function lets you know in which environment Ninox is currently executed.
Your return values could be
web (on Ninox cloud)
mac (on the Ninox Mac app)
iphone (on the Ninox iPhone app)
ipad (on the Ninox iPad app)
android (on the Ninox app on an Android phone)
tab (on the Ninox app on an Android tablet)
server (if the function is executed on the server)
This function is quite handy if you use Ninox on different platforms and you'd like to execute an alternative script depending on the platform, for example for your forms.
To adjust your form according to your platform, you could show or hide placeholders based on the respective platform.
ninoxApp()
string
Result: tab (if you check it on your Android tablet)
Result: Yes (if you check in your browser)
If added in the field Display field only, if in the field settings, you'll see the respective field only in your browser.
To open a record in a given layout in the print layout editor
This function will open a specific print layout of a given record.
openPrintLayout(nid, string)
void
Result: Will open the print layout called Invoice of the current record.
printAndSaveRecord
, which saves a given record in a given layout as PDF in the internal file system and returns the path as a link.
printRecord
, which prints to a PDF from a given record in a given layout and opens the file with a program set as default.
To jump to the related table and open a given record
This function closes your current form and opens the form of the given record together with the respective table. If you want, you can also specify the tab that should be opened.
To open the form of a record without leaving your current table, use popupRecord()
.
The function can be executed only on the client. Learn more about execution context
openRecord(nid)
openRecord(nid, string)
void
openRecord(myRecord)
To jump to the related table and open a given record.
Result: Opens the Customers table and the form of the first record.
openRecord(myRecord, tabName)
To jump to the related table and open a given tab of a given record.
Result: Opens the Customers table and the form of the first record with the Company information tab selected.
openTable
, which opens a given table.
popupRecord
, which opens a given record in a pop-up form.
To open a given page
This function closes the current page and opens the given page. You can specify the request by adding a tab you want the page to be opened with.
If you didn't add a specific tab, the "default" or the last active tab will be opened.
openPage(string)
openPage(string, string)
void
Result: The Invoices page opens.
openPage(myPage, myTab)
To open a given page with a given tab.
Result: The Current month tab of the Invoices page opens.
openTable
, which opens a given table.
openRecord
, which jumps to the related table and opens a given record.
popupRecord
, which opens a given record in a pop-up form.
To return a structured list or array of rows and data from specified CSV text
The parseCSV
function parses CSV-formatted text into a structured list or array. You can customize parsing behavior by setting headers, separators, and text quote characters.
parseCSV(string, json)
data (string): The CSV text input. Example: "Name,Age\nKiran,42\nLisa,27"
options (JSON object): Optional configuration, with the following properties:
firstLineIsHeader: boolean
, default is false
. If true
, the first line is treated as column headers.
separator: string
. Sets the delimiter between fields, such as ","
or ";"
. Auto-detects if not specified.
textQuote: string
. Specifies the character used to quote text fields. Default is "
(double quotes).
[JSON]: A list or an array of JSON objects, with keys from the header if firstLineIsHeader
is true
.
[[text]]: A list or an array of text arrays (rows), if firstLineIsHeader
is false
.
firstLineIsHeader=false
Example:
Or explicitly set firstLineIsHeader
to false
:
Result:
firstLineIsHeader=true
Example:
Result:
Note: If no separator
is specified, parseCSV
will auto-detect a common delimiter like commas or tabs based on the input structure.
Example:
Result:
textQuote
Note: Use textQuote
to specify a character for quoting fields. It's optional to quote every field; parseCSV
will still correctly read unquoted fields.
In this example, text fields are quoted with single quotes.
Example:
Result:
textQuote
characterYou can set a textQuote
character, such as a single quote ('
), to handle fields with quoted text specifically.
Example:
Result:
To convert a given value to a number
It returns the values of different data types as a number. You can imagine this is needed quite often!
The result depends on the data type. Some examples:
A text consisting only of digits is converted to a number, for example,
date and time are mapped in Unix time.
In an appointment, Ninox refers by default to the start, if you don't explicitly refer to the end with endof()
.
A time interval will be converted to milliseconds.
Applied to a choice field, it returns the number of the selected option.
number(any)
number
Result: 1638226800000 (for example on November 30, 2021 in Germany)
Result: 75639 (the text is now a number and can be processed in further calculations)
appointment
, which converts given time-related values to an appointment.
date
, converts to or returns a date value.
datetime
, converts to or returns a timestamp
text
, which converts a value to a string and possibly reflects the format options.
time
, which returns the current time.
To open a given table
This function closes the current table and opens a given table. You can specify the request by adding a view you want the table to be opened with.
If you didn't add a specific view, the "default" or the last active view will be opened.
openTable(string)
openTable(string, string)
void
Result: The Invoices table opens.
openTable(myTable, myView)
To open a given table with a given view.
Result: The Current month view of the Invoices table opens.
, which opens a given page.
, which jumps to the related table and opens a given record.
, which opens a given record in a pop-up form.
To return Yes (true) if the number is odd
With this function, you can check whether a number is odd, i.e. not divisible by 2 without remainder. The return value is either Yes (true
) or No (false
). 0 is evaluated as even, and therefore returns No (false
).
odd(number)
boolean
Result: No (false
)
Result: Yes (true
)
Result: No (false
)
Result: Yes (true
)
even
which returns Yes (true
) if the number is even.
To return Yes (true) if the edit mode is active
With this function, you'll find out if the current user is in edit mode, i.e. the wrench icon is activated (red).
isAdminMode()
boolean
Result: Yes (true
) if you activated the wrench icon to edit your database
isDatabaseLocked
, which returns Yes (true
) if the database is locked.
isDatabaseProtected
, which returns Yes (true
) if the database is protected by a password.
userIsAdmin
, which returns Yes (true
) if the current user has the admin role.
To open a given record in fullscreen mode
This function will open the form view to fullscreen. Specify the record, which you'd like to show in fullscreen mode.
If you want, you can also specify the tab that should be opened.
If you use this function, the form view will cover the entire window. To close this fullscreen view, click on the in the top left corner.
openFullscreen(nid)
openFullscreen(nid, string)
void
Result: The current record will be shown on fullscreen with the default tab selected.
Result: The current record will be shown on fullscreen with the Company information tab selected.
closeFullscreen
, which closes fullscreen mode.
To return the IDs of the selected choice values of a given multiple-choice field
With this function, you'll get the IDs of the selected options.
Multiple-choice field: You get the choice IDs
Dynamic multiple-choice field: You get the record IDs
numbers(multi)
numbers(dmulti)
[number]
We have a multiple-choice field Favorite sports with the following choice values:
Basketball, Dancing, Sailing, and Soccer are selected.
numbers(myMultiChoice)
To return the internal IDs of the selected choice values of a given multiple choice field.
Result: [1,3,4,5]
numbers(myDynMultiChoice)
To return the record IDs of the selected choice values of a given dynamic multiple choice field.
Result: [1,3,4,5]
In this example, Favorite sports is a dynamic choice field that refers to the Sports table.
You can change dynamically table views based on the selection of your dynamic choice field.
The following script is to be added to the formula field of the table view.
Result: You see the records of the employees in the table view that are selected in the dynamic multiple choice field.
chosen
, which evaluates multiple-choice fields.
To convert a string to a link and open it in the standard web browser
With this function, you can open a website in your default browser. You can pass any string, the function will encode it to make sure it's a valid link.
The function can be executed only on the client. Learn more about
openURL(string)
void
openURL(link)
To convert a string to a link and open it in the standard web browser.
Result: Google Maps will open and show the Ninox office.
, which returns a rich text representation of any value.
, which sends an HTTP request.
To convert a JSON string to a JSON object
This function converts a string to a JSON object.
The string needs to be written as a valid JSON object. Otherwise, the function will return unuseful stuff. Not good.
This can be quite handy if you need to modify a JSON object and pass it on in the http()
function.
parseJSON(string)
JSON
parseJSON(jsonString)
To convert a JSON string to a JSON object.
Use double quotes ("") for quotes within a string.
Result: {"test":123}
, which creates a JSON string of a valid JSON object.
Favorite sport
ID
Selection
Basketball
1
x
Climbing
2
Dancing
3
x
Sailing
4
x
Soccer
5
x
To open a given record in a pop-up form
This function opens the form of the given record as a pop-up. If you want, you can also specify the tab that should be opened.
To open the form of a record and the respective table simultaneously, use openRecord()
.
The function can be executed only on the client. Learn more about execution context
popupRecord(nid)
popupRecord(nid, string)
void
popupRecord(myRecord)
To open a given record in a pop-up form.
Result: The first record of the Customers table opens in a pop-up form.
popupRecord(myRecord, tabName)
To open a given record with a given tab in a pop-up form.
Result: Opens the form as a popup of the first record of the Customers table with the Company information tab selected.
openRecord
, which jumps to the related table and opens a given record.
To calculate the power of a number
The function returns the power of a base number using the exponent. If the exponent has the value 0.5, the result is the root of the base number.
pow(number, number)
number
pow(x,y)
To calculate the power of a base x using the exponent y.
Result: 64
Result: 8
Result: 3.9999999999999996
To convert a value to a phone value
With this function, you can display a formula field as a phone field with a call button. By clicking on the button, you can place a call via your phone client.
There is no validation if the passed content is a phone number indeed.
This is quite useful if you have a text which contains a phone number, and you'd like to extract the phone number to convert it to a callable phone number.
phone(any)
phone
phone(myNumber)
To convert a number to a phone value.
Result: The phone number will be shown as a phone field (see above) where you can place a phone call directly.
phone(string)
To convert a string to a phone value.
Result: +1 212 567 89 10 (Shows the phone number of the linked table Customer.
You receive a message like this:
Hey Claudia,
here’s my phone number: +49 30 123 456 78.
Please give me a call, so we can discuss what we will include in our next presentation.
Kind regards, Sam
With a regular expression, you filter the phone number, which will be shown in your respective formula field.
Result: +49 30 123 456 78 (Extracts the phone number out of the text message and shows it in a field with the call button.
To convert a given value to an email value
To convert an XML string to a JSON object
This function converts an XML string to a JSON object. The function is of particular interest for connections to external services via API and the processing of corresponding data.
XML is beside JSON a common format to exchange data over the internet.
parseXML(string)
JSON
parseXML(xml)
To convert an XML string to a JSON object. An invalid string will return a parse error.
We convert an XML string to a JSON object, which contains a note to Captain America to hand it over to an external service, for example an email service provider.
Result:
{"note":{"to":{"@":"Captain America"},"from":{"@":"Ninox"},"heading":{"@":"Save the world!"},"body":{"@":"Hey Cap, please save the world!"}}}
formatXML
To convert a given JSON object into XML text, which might be optically structured