# Work with functions

Functions are the building blocks of Ninox logic. They help you calculate values, format text, work with dates, filter records, and more.

If you are new to functions, start with the parameter syntax below. Once you can read entries like `text(any)` or `count([any])`, the rest of the reference becomes much easier to use.

## **Understand function parameters**

Function entries show what a function expects. Read them from left to right:

* the function name tells you what it does
* the part in parentheses shows the expected input

This helps you see quickly whether a function fits your task.

For example:

* `odd(number)` expects a number
* `text(any)` can convert many value types to readable text
* `count([any])` expects a list, array, or selection

### **What `any` means**

`any` means the function can work with different value types. Ninox converts or interprets the value inside the function. For example, `text(any)` can turn a number, date, choice, or other value into text.

This is more flexible than a function like `odd(number)`, which expects a number.

{% hint style="info" %}
`any` does not mean every value is equally useful. Pass a value that makes sense for the function you are using.
{% endhint %}

### **What `[any]` means**

`[any]` means the function expects a list of values. If you are new to scripting, read square brackets as “a list of.”

This is usually:

* an array
* a record selection
* a list of field values

For example:

* `count([any])` counts items in a list or selection
* `first([any])` returns the first item
* `concat([any])` joins values into text

The items in that list can be different types, depending on the function.

### **When a function returns `any`**

If a function returns `any`, the result can vary. For example, one function can return:

* text in one case
* a number in another
* a record or JSON value in another

Check the function description and example to see what result to expect.

{% hint style="info" %}
If you are just getting started, focus on the input first. The examples usually make the result clear.
{% endhint %}

### **When a function expects `JSON`**

Some functions need several related values at once. JSON is a compact way to group them together.

Each entry has a name on the left and a value on the right. In the documentation, this is labeled as `JSON`.

You write them with curly braces:

```ninox
sendEmail({
	from: "support@example.com",
	to: "customer123@example.com",
	subject: "Thank you for your email",
	text: "We received your request."
})
```

In this example:

* `from` is the sender address
* `to` is the recipient address
* `subject` is the email subject
* `text` is the message body

Use this pattern when a function needs several named values such as `to`, `subject`, or `text`.

Common examples are:

* `sendEmail(JSON)`
* `http(..., JSON)`
* `printRecord(..., JSON)`

{% hint style="info" %}
`JSON` here means a value you pass directly, for example `{to: "a@example.com"}`. It does not mean quoted text like `"{\"to\":\"a@example.com\"}"`.
{% endhint %}

### **Other parameter labels you will see**

Some labels show a type. Others show the role of the value.

For example, `number`, `date`, and `record` are type labels. Labels like `pattern`, `separator`, `from`, and `to` show how that argument is used in the function.

Read both together:

* the label tells you the kind of value
* the description tells you how that value is used

## **Parameter glossary**

This section covers the parameter labels used across the function chapters below.&#x20;

<table><thead><tr><th width="318.8984375">Label</th><th>Meaning</th></tr></thead><tbody><tr><td><code>any</code></td><td>Any value type that the function can interpret or convert</td></tr><tr><td><code>[any]</code></td><td>A list of values</td></tr><tr><td><code>appointment</code></td><td>One value that contains a start and end together</td></tr><tr><td><code>background</code></td><td>A background color or style value</td></tr><tr><td><code>base</code></td><td>The base number in a logarithm or power expression</td></tr><tr><td><code>boolean</code></td><td><code>true</code> or <code>false</code></td></tr><tr><td><code>choice</code></td><td>A value from a single choice field</td></tr><tr><td><code>date</code></td><td>A date value without a time</td></tr><tr><td><code>datetime</code></td><td>A local date and time value</td></tr><tr><td><code>year, month, day</code></td><td>Numeric date parts</td></tr><tr><td><code>dmulti</code></td><td>A dynamic multiple choice field</td></tr><tr><td><code>exponent</code></td><td>The power applied to a base number</td></tr><tr><td><code>field</code></td><td>A field object</td></tr><tr><td><code>file</code></td><td>One file object or attachment reference</td></tr><tr><td><code>[file]</code></td><td>A list of file objects</td></tr><tr><td><code>flags</code></td><td>Optional regular expression options</td></tr><tr><td><code>fontColor</code></td><td>A text color value</td></tr><tr><td><code>hour, minute, second, millisecond</code></td><td>Numeric time parts</td></tr><tr><td><code>icon</code></td><td>An icon name or icon value</td></tr><tr><td><code>id</code></td><td>A numeric ID</td></tr><tr><td><code>JSON</code></td><td>A structured object with named values</td></tr><tr><td><code>language</code></td><td>A language code for localized output</td></tr><tr><td><code>length</code></td><td>A target length or number of characters</td></tr><tr><td><code>link</code></td><td>A link value, often a file link</td></tr><tr><td><code>location</code></td><td>A location value with coordinates</td></tr><tr><td><code>milliseconds</code></td><td>Unix time in milliseconds</td></tr><tr><td><code>multi</code></td><td>A multiple choice field</td></tr><tr><td><code>name</code></td><td>A name, for example for a color</td></tr><tr><td><code>nid</code></td><td>A Ninox record ID</td></tr><tr><td><code>number</code></td><td>A numeric value</td></tr><tr><td><code>[number]</code></td><td>A list of numeric values</td></tr><tr><td><code>options</code></td><td>A settings object for one specific function</td></tr><tr><td><code>padding</code></td><td>The characters used to pad text</td></tr><tr><td><code>pattern</code></td><td>A format pattern or regular expression</td></tr><tr><td><code>period</code></td><td>A calendar unit such as <code>"day"</code>, <code>"week"</code>, or <code>"month"</code></td></tr><tr><td><code>r, g, b, a</code></td><td>Red, green, blue, and optional opacity values</td></tr><tr><td><code>record</code></td><td>One record from a table</td></tr><tr><td><code>[record]</code></td><td>A list or selection of records</td></tr><tr><td><code>replacement</code></td><td>The value that replaces a match</td></tr><tr><td><code>script</code></td><td>An expression or logic block that Ninox evaluates</td></tr><tr><td><code>search</code></td><td>The value or text to look for</td></tr><tr><td><code>start, end</code></td><td>Starting and ending values or positions</td></tr><tr><td><code>separator</code></td><td>A text separator or split marker</td></tr><tr><td><code>step</code></td><td>The increment in a numeric range</td></tr><tr><td><code>string</code></td><td>Plain text, such as a name, label, URL, or field name</td></tr><tr><td><code>[string]</code></td><td>A list of text values</td></tr><tr><td><code>table</code></td><td>A table object</td></tr><tr><td><code>text</code></td><td>Text input; usually the source text in string functions</td></tr><tr><td><code>time</code></td><td>A time-of-day value</td></tr><tr><td><code>timestamp</code></td><td>A UTC-based time value</td></tr><tr><td><code>from, to</code></td><td>Start and end values or positions</td></tr><tr><td><code>unit</code></td><td>A duration unit such as <code>"minutes"</code> or <code>"days"</code></td></tr><tr><td><code>user</code></td><td>A workspace user value</td></tr><tr><td><code>value, value1, value2, ...</code></td><td>Generic input values passed singly or separately</td></tr></tbody></table>

### **Quick reading tips**

* plain labels like `number` or `record` show the expected type
* square brackets like `[number]` or `[file]` mean “a list of”
* labels like `pattern`, `separator`, `from`, or `subject` describe the argument’s role

## **Explore functions by category**

Once the syntax feels familiar, use these categories to find the right function faster:

* [Text and strings](/ninox-scripting/automate-your-workflows/work-with-functions/text-and-strings.md): combine, clean, and format text.
* [Numbers and math](/ninox-scripting/automate-your-workflows/work-with-functions/numbers-and-math.md): do calculations, rounding, and aggregates.
* [Dates and time](/ninox-scripting/automate-your-workflows/work-with-functions/dates-and-time.md): work with dates, durations, and schedules.
* [Records and tables](/ninox-scripting/automate-your-workflows/work-with-functions/records-and-tables.md): select, count, and manage records.
* [User Interface and navigation](/ninox-scripting/automate-your-workflows/work-with-functions/user-interface.md): show dialogs, open pages, print layouts.
* [Files and export](/ninox-scripting/automate-your-workflows/work-with-functions/files-and-export.md): import, create, and share files.
* [Users and roles](/ninox-scripting/automate-your-workflows/work-with-functions/users-and-roles.md): personalize behavior based on user info.
* [Location and devices](/ninox-scripting/automate-your-workflows/work-with-functions/location-and-devices.md): use GPS, phone, and URLs.
* [Integration and HTTP](/ninox-scripting/automate-your-workflows/work-with-functions/integration-and-http.md): connect to external services.
* [System and flow control](/ninox-scripting/automate-your-workflows/work-with-functions/system-and-flow-control.md): handle caching, timing, and environment checks.

If you need the full reference, go to the [Functions library](/ninox-scripting/functions-and-script-library/functions-library.md). It gives you a complete overview of documented functions in one place, including an alphabetical list for quick lookup.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ninox.com/ninox-scripting/automate-your-workflows/work-with-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
