> For the complete documentation index, see [llms.txt](https://docs.ninox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ninox.com/ninox-scripting/automate-your-workflows/work-with-functions/user-interface.md).

# User interface

Learn how to show messages and navigate users with Ninox scripts.

User interface and navigation functions shape what users see and where they go next. This chapter shows you how to guide users and navigate your app.

{% hint style="info" %}
All UI-bound functions in this chapter run only on the client. They have no effect on the server.
{% endhint %}

<table><thead><tr><th width="224.484375">Function (A-Z)</th><th>Task</th></tr></thead><tbody><tr><td><code>alert()</code></td><td>Show a simple message</td></tr><tr><td><code>closeAllRecords()</code></td><td>Close all open record views</td></tr><tr><td><code>closeFullscreen()</code></td><td>Exit full screen mode</td></tr><tr><td><code>closeRecord()</code></td><td>Close the current record view</td></tr><tr><td><code>dialog()</code></td><td>Show a dialog with answer options</td></tr><tr><td><code>openFullscreen()</code></td><td>Open a record in full screen</td></tr><tr><td><code>openPage()</code></td><td>Open a page</td></tr><tr><td><code>openPrintLayout()</code></td><td>Open a record in a print layout</td></tr><tr><td><code>openRecord()</code></td><td>Open a record in its table</td></tr><tr><td><code>openTable()</code></td><td>Open a table</td></tr><tr><td><code>popupRecord()</code></td><td>Open a record in a pop-up</td></tr></tbody></table>

## Show messages and call up records

Use these functions when you want to guide users with a message or show record details without changing the main view.

### Show a simple message with `alert()`

Use `alert()` to show a pop-up with a message and an **OK** button.

Use it when you want to:

* Confirm a successful action.
* Warn about missing input.
* Show information the user should acknowledge before continuing.

`alert(any)`

* `any` the value or message to show

`alert()` returns no value.

#### Let's take a look at some examples:

```ninox
alert("I am a pop-up. Please click 'OK' to confirm.")
```

Shows a pop-up with an **OK** button.

```ninox
alert("This was the time at the very moment you clicked the button: " + time(now()) + ".")
```

Shows the current time when the pop-up opens.

Tips:

* Keep messages short.
* `alert()` runs only on the client.
* If one script calls `alert()` several times, only the last call is shown.
* Use `dialog()` when users need a choice, not just confirmation.

### Ask for confirmation with `dialog()`

Use `dialog()` to show a dialog with a title, message, and answer options.

Use it when you want to:

* Ask users to confirm a decision.
* Let users choose between clear answers such as `Yes` and `No`.

`dialog(string, string, [string])`

* first `string` the dialog title
* second `string` the dialog message
* third `[string]` the answer options to show

`dialog()` returns the selected answer as a string.

The script waits until the user picks an answer.

#### Let's take a look at some examples:

```ninox
dialog("Confirm", "Are you sure you want to delete the record?", ["Yes", "No"])
```

Opens a confirmation dialog for a delete action.

```ninox
let title := "Delete record";
let message := "Should this record be deleted? Are you 100% sure?";
let answerOptions := ["Yes, get rid of it.", "No! I still need it!"];
if dialog(title, message, answerOptions) = "Yes, get rid of it." then
    delete this
end
```

Deletes the current record only if the user confirms.

```ninox
dialog("Duplicate!", "Do you want to keep the duplicated product name?", ["No", "Yes"])
```

The user is asked to double-check the questionable input.

Tips:

* `dialog()` runs only on the client.
* Store the result in a variable when later steps depend on the answer.

## Open pages, tables, records, and layouts

Use these functions to move users to the next relevant place in the app. Display records from other tables without leaving the current view or jump directly to a print layout.

### Open a page with `openPage()`

Use `openPage()` to call up a page by name.

Use it when you want to:

* Guide users through your app with buttons and triggers.

`openPage(string)`

* `string` the page **Label** or **Internal name** as text

`openPage()` closes the current page, form, or table and opens the selected page.

#### Let's take a look at some examples:

```ninox
openPage("dashboard")
```

Opens the page named "Dashboard".

```ninox
openPage("invoices_overview")
```

Opens the page with the internal name "invoices\_overview".

{% hint style="info" %}
The string in the function is case-insensitive.
{% endhint %}

{% hint style="warning" %}
If you change a page's **Label** or **Internal name**, update the string in this function too. Ninox cannot update it automatically.
{% endhint %}

Tip:

* If the page has tabs, Ninox opens the first tab.

### Open a table with `openTable()`

Use `openTable()` to open a table by name.

Use it when you want to:

* Route users through your app with buttons and triggers.

`openTable(string)`

* `string` the table **Label** or **Internal name**

`openTable()` closes the current table or page and opens the selected table.

#### Let's take a look at an example:

```ninox
openTable("invoices")
```

Opens the "Invoices" table.

{% hint style="info" %}
The string in the function is case-insensitive.
{% endhint %}

{% hint style="warning" %}
If you change a table's **Label** or **Internal name**, also update the string in this function. Ninox cannot update the string automatically.
{% endhint %}

Tip:

* Ninox opens the first view of the table.

### Open a record with `openRecord()`

Use `openRecord()` to open a record directly.

Use it when you want to:

* Route users through your app with buttons and triggers.
* Open a specific record to work with it.

`openRecord(nid)`

* `nid` the record you want to open

`openRecord()` closes the current form. If the target record is in another table, it also closes the current table. It then opens the target record's table and form view.

#### Let's take a look at some examples:

```ninox
openRecord(record(settings, 1))
```

Opens the record with the ID 1 in the "Settings" table.

```ninox
openRecord(first(select customers where name = "John Doe"))
```

Opens the "Customers" table and the first record whose "Name" field is "John Doe".

Tips:

* `openRecord()` runs only on the client.
* Use `popupRecord()` instead when a quick preview is enough and users should stay in the current table.

### Call up a record with `popupRecord()`

Use `popupRecord()` to show a record in a pop-up.

Use it when you want to:

* Open and work on a specific record briefly without leaving your workflow.

`popupRecord(nid)`

* `nid` the record you want to preview

#### Let's take a look at some examples:

```ninox
popupRecord(record(settings, 1))
```

Opens the record with ID 1 from the "Settings" table in a pop-up form.

```ninox
popupRecord(first(select customers where name = "Jane Roe"))
```

Opens the first "Customers" record whose "Name" field is "Jane Roe" in a pop-up form.

Tips:

* `popupRecord()` runs only on the client.
* Use `record()` instead of `select` to retrieve a record. It is much faster for large tables.

### Open a print layout with `openPrintLayout()`

Use `openPrintLayout()` to open a specific print layout for a record.

Use it when you want to:

* Open a specific print layout for a specified record.

`openPrintLayout(nid, string)`

* `nid` record you want to show in the print layout
* `string` print layout name

{% hint style="info" %}
The string in the function is case-insensitive.
{% endhint %}

#### Let’s take a look at some examples:

```ninox
openPrintLayout(this, "Invoice")
```

Opens the print layout "Invoice" for the current record.

```ninox
let myInvoice := first(select invoices where text(status) = "Approved");
openPrintLayout(myInvoice, "invoice pdf")
```

Finds the first record in the "Invoices" table with the "Status" field set to "Approved". It then opens the record in the "Invoice pdf" print layout.

## Change the current view

Use these functions when you want to switch display modes or clean up open record windows.

### Enter or leave full screen with `openFullscreen()` and `closeFullscreen()`

Use these functions to open a record in its form view in full screen or exit full screen mode.

`openFullscreen(nid)`\
`closeFullscreen()`

* `nid` the record you want to open in full screen

#### Let’s take a look at some examples:

```ninox
openFullscreen(this)
```

Opens the current record in full screen.

```ninox
closeFullscreen()
```

Exits full screen mode and returns to the previous view.

Tip:

* `openFullscreen()` covers the entire window with the form view.

### Use `closeRecord()` and `closeAllRecords()` to close open form views

Use these functions when you want to:

* Return users to the underlying page or table.
* Close several stacked form views quickly.

`closeRecord()`\
`closeAllRecords()`

#### Let's take a look at some examples:

```ninox
closeRecord()
```

Closes the current record view. Users then see the form below it, or the current table view if no other form is open.

```ninox
closeAllRecords()
```

Closes all open record views and returns users to the current table view.

Tips:

* Close only what you need.
* Avoid combining several open and close actions in one script unless the flow is obvious.

## Common UI and navigation recipes

These short patterns cover common ways to guide users through an app.

### Show short success feedback

```ninox
alert("✔ Email sent!")
```

Shows immediate feedback after a successful action.

### Ask for delete confirmation

```ninox
dialog("Confirm", "Delete this record?", ["Yes", "No"])
```

Prompts the user before a destructive action.

### Stay in your workflow while creating new records

```
let new := create customers;
new.creation_date := today();
popupRecord(new)
```

Create records in another table without leaving your current workflow. Use a button to create the record, then open it in a pop-up form to add more data.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
