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:
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 iffor more than two outcomesswitch ... casefor fixed optionsselect ... whereto filter recordsorder byto sort recordsfor ... in ... do ... endto loop through records or list itemsfor ... from ... to ... do ... endto 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
trueandfalseDate, 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.
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 equallikechecks whether text contains a value
Examples:
if status = "Open" then alert("Order is open") endif status != "Closed" then alert("Still active") endif total > 100 then alert("High value") endif age < 18 then alert("Young") endif total >= 30 then "Card" else "Cash" endif "Hello" like "el" then "Yes" else "No" end
Logical operators
Use logical operators to combine conditions:
andmeans both conditions must be trueormeans only one condition must be true
Examples:
if is_active and age > 18 then alert("Eligible") endif 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 valuesuse
+,-,*,/to calculateuse
=,!=,>,<,>=,<=to compareuse
.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 valuesdate()to build a datealert()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:
You do not need to learn everything at once. Start with short scripts, test often, and build confidence one pattern at a time.
Last updated
Was this helpful?