Explore core scripting elements

Learn the core building blocks of Ninox scripting, including statements, variables, data types, operators, and built-in functions.

Scripting gets easier once you learn a few small patterns. In Ninox, most scripts read values, make a decision, or update data. Once these basics feel familiar, the deeper scripting chapters get much easier.

In Ninox scripting refer to field or table names with the internal name and not the label. Internal names are autogenerated and do not contain any spaces or special characters. If your field is labeled "First name", the autogenerated internal name is first_name. If your field or table is labeled containing special characters like ( or . the autogenerated internal name replaces these with underscores. For example, the field label "My.Customers (New)" would have the autogenerated internal name my_customers_new. You can change the internal names at any time. Keep in mind to use only lowercase letters (a-z), numbers (0-9), and underscores.

In this guide, you will learn how to:

  • work with statements and variables

  • choose the right data types

  • use operators

  • call built-in functions

  • control logic with common scripting patterns

If you are new to scripting, start with a Button. You click it, see the result, and adjust fast.

Understand statements in Ninox

A statement is one instruction. A script is a series of statements.

Common Ninox statements are:

Statement
What it does

let

Defines a variable that is populated with a value

if ... then ... else ... end

Makes a decision based on conditions

for ... do ... end

Repeats logic for several records

while ... do ... end

Repeats while a condition stays true

alert()

Shows a message

select()

Finds records

create()

Creates a record

delete()

Deletes one or multiple records

You will also see these patterns often:

  • else if for more than two outcomes

  • switch ... case for fixed options

  • select ... where to filter records

  • order by to sort records

  • for ... in ... do ... end to loop through records or list items

  • for ... from ... to ... do ... end to loop through a numeric range

Try this as your first script:

This script opens a message when the button runs.

Why this is a good first example:

  • you see the result immediately

  • it is easy to test

  • it helps you understand where the script output appears

Work with data types and variables

Before you write logic, check what kind of value you are working with. A number behaves differently from text, a date, or a record.

A field is something you add in Builder mode. A data type is the kind of value your script reads, stores, or returns.

What is a data type in Ninox?

A data type defines what a value is. Choosing the correct type keeps conditions, calculations, and comparisons reliable.

Common field-to-type mappings are:

  • Text and Multi-line text fields return Text

  • Number fields return Number

  • Yes/no fields return Yes or No

  • Date fields return Date

  • Date and time fields return Timestamp

  • Time fields return Time

  • Duration fields return Timeinterval

  • Relationship fields return Record(s)

Some expressions return Array or JSON values.

Common scripting data types are:

  • Text for labels, messages, and names

  • Number for values you calculate with

  • Yes/No for true and false

  • Date, Time, and Datetime for time-based logic

  • Record for one linked record

  • Array for lists of values or records

  • JSON for structured key-value data

  • File, Location, and User for specialized values

What is a variable?

A variable stores a value for later use. Variables make scripts easier to read, test, and reuse. If you can store one value and reuse it, you already understand the core idea.

1

Create a variable

This stores the number 100 in the variable total.

2

Change the value

This adds 50 to the current value. total is now 150.

3

Use the value in a condition

This checks the value and returns "High" or "Low".

Use operators to calculate and compare

Operators tell Ninox what to do with values. They help you calculate, compare, and combine conditions.

Arithmetic operators

Use arithmetic operators for calculations:

  • + adds values

  • - subtracts values

  • * multiplies values

  • / divides values

  • % returns the remainder after integer division

  • () changes the order of calculation

Examples:

  • let sum := 10 + 5;

  • let difference := 20 - 8;

  • let product := 4 * 3;

  • let ratio := 20 / 4;

  • 13 % 5

  • (1 + 2) * 3

Comparison operators

Use comparison operators to check values:

  • = checks whether two values are equal

  • != checks whether two values are different

  • > checks whether one value is greater

  • < checks whether one value is smaller

  • >= checks whether one value is greater or equal

  • <= checks whether one value is smaller or equal

  • like checks whether text contains a value

Examples:

  • if status = "Open" then alert("Order is open") end

  • if status != "Closed" then alert("Still active") end

  • if total > 100 then alert("High value") end

  • if age < 18 then alert("Young") end

  • if total >= 30 then "Card" else "Cash" end

  • if "Hello" like "el" then "Yes" else "No" end

Logical operators

Use logical operators to combine conditions:

  • and means both conditions must be true

  • or means only one condition must be true

Examples:

  • if is_active and age > 18 then alert("Eligible") end

  • if status = "Open" or status = "Pending" then alert("Order not closed") end

Other operators and syntax you will see often

You will see these building blocks in many scripts:

  • := assigns a value to a field or variable

  • ; ends a statement

  • " " wraps text values

  • . accesses a field or value on a record or JSON object

If you are unsure which operator to use, start with this rule:

  • use := to store values

  • use +, -, *, / to calculate

  • use =, !=, >, <, >=, <= to compare

  • use . to access fields (including reference fields) on a record

Use built-in functions to save time

Functions are ready-made statements or scripts. You call them instead of writing everything from scratch. They save time because they solve common tasks for you.

Typical examples are:

  • sum() to total values

  • date() to build a date

  • alert() to show a message

You do not need to memorize them all. Start with a few common ones and build from there.

For a full list, see Work with functions.

What to learn next

Once these basics make sense, continue with:

Last updated

Was this helpful?