For the complete documentation index, see llms.txt. This page is also available as Markdown.

System and flow control

Learn how to pause scripts, inspect the app execution context.

System and flow control functions help you manage timing, sync, caching, and environment-specific behavior. You can pause a script, inspect raw values, and detect app context.

In this chapter, you will learn how to:

  • Control timing in a running script.

  • Inspect the current app environment and database status.

Function (A-Z)
Task

eval()

Execute text as a script

ninoxApp()

Return the current client or app context

raw()

Return the internal text representation

sleep()

Pause a script briefly

Control timing and execution order

Use these functions when one action should happen only after another has completed.

Pause a script briefly

Use sleep() to force Ninox to wait for a given number of milliseconds before the script continues.

Use it when you want to:

  • Add a short delay before a follow-up action.

  • Avoid timing issues in a UI flow.

  • Wait briefly for another process to settle.

  • Show a note or warning before the next step runs.

sleep(number)

  • number the delay in milliseconds

sleep() returns no value.

Let’s take a look at some examples:

Pauses the script for 2 seconds.

Tips:

  • Keep delays as short as possible.

  • Use a delay only when the flow really needs it.

Inspect raw values and range boundaries

Use these functions when you need the underlying value or the start boundary of a duration or range context.

Inspect the raw value

Use raw() to return the internal raw text representation of a value.

Use it when you want to:

  • Convert formatted text into its raw text form.

  • Read the internal value behind a color field.

  • Reuse formatted content in dialogs or emails.

  • Compare the raw form with the displayed form.

raw(any)

  • any the value you want in raw form

raw() returns a string.

Let’s take a look at some examples:

Returns the content of a formatted text value as unformatted text with HTML tags.

Displays a dialog with the contents of the formatted text field Dialog text.

Returns the internal color value, for example #EC87E2.

Tips:

  • Use raw() when you need the system's internal text representation.

  • This is useful for formatted text fields, dialogs, and emails.

  • You can format the result again later with html().

Execute strings as formulas and inspect data with eval()

Use eval() to execute text as a script.

This lets you create dynamic expressions. For example, use table, field, and variable names that change at runtime.

eval(string, nid)

  • string text containing calculations or a Ninox script

  • nid the record to which the script applies

Let’s take a look at some examples:

Returns 20 if the current record's "Manual formula" field contains "14 + 6 * 0.5 * 2".

Returns the sum of all amounts in the "Invoices" table.

Shows an alert with the message "This is a test".

Returns the value "Toni Kim" from the "Full name" field. For a choice field, it returns the value's index.

Returns the text value of a choice field.

Returns the number of records in the "Contacts" table whose "Full name" field matches the selected field value in the current record. Use this approach for dynamic duplicate searches when myField is selected from a choice field.

Detect app context and database state

Use these functions when your script should react to the current client or the protection status of the database.

Detect the current app with ninoxApp()

Use ninoxApp() to check where your script is executed.

Use it when you want to:

  • Adjust behavior by client.

  • Diagnose client-specific workflows.

ninoxApp()

ninoxApp() returns a string that identifies the current environment.

Possible return values include:

  • client

  • server

Let’s take a look at some examples:

Returns a string where the script is running.

Tips:

  • Use ninoxApp() to check if your UI-based functions can be executed, which is not the case if the result is "server".

Last updated

Was this helpful?