# Nutzeroberfläche

Diese Funktionen steuern, was Nutzer sehen. In diesem Kapitel lernst du, wie du Meldungen anzeigst und Entscheidungen abfragst.

{% hint style="info" %}
Alle UI-Funktionen in diesem Kapitel laufen nur auf dem Client. Auf dem Server haben sie keine Wirkung.
{% endhint %}

<table><thead><tr><th width="224.484375">Funktion (A-Z)</th><th>Aufgabe</th></tr></thead><tbody><tr><td><code>alert()</code></td><td>Zeigt eine einfache Meldung an</td></tr><tr><td><code>dialog()</code></td><td>Zeigt einen Dialog mit Antwortoptionen an</td></tr></tbody></table>

## Meldungen anzeigen und Bestätigungen abfragen

Nutze diese Funktionen, wenn du Nutzer mit einer Meldung führen oder eine Bestätigung abfragen willst.

### Mit `alert()` eine einfache Meldung anzeigen

Nutze `alert()`, um ein Pop-up mit einer Meldung und einer **OK**-Schaltfläche anzuzeigen.

Nutze es, wenn du:

* eine erfolgreiche Aktion bestätigen willst.
* auf fehlende Eingaben hinweisen willst.
* Informationen anzeigen willst, die Nutzer vor dem Fortfahren bestätigen sollen.

`alert(any)`

* `any`: der Wert oder die Meldung, die angezeigt werden soll

`alert()` gibt keinen Wert zurück.

#### Schauen wir uns einige Beispiele an:

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

Zeigt ein Pop-up mit einer **OK**-Schaltfläche an.

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

Zeigt die aktuelle Uhrzeit an, wenn sich das Pop-up öffnet.

Tipps:

* Halte Meldungen kurz.
* `alert()` läuft nur auf dem Client.
* Wenn ein Skript `alert()` mehrmals aufruft, wird nur der letzte Aufruf angezeigt.
* Nutze `dialog()`, wenn Nutzer eine Auswahl treffen sollen.

### Mit `dialog()` eine Bestätigung abfragen

Nutze `dialog()`, um einen Dialog mit Titel, Meldung und Antwortoptionen anzuzeigen.

Nutze es, wenn du:

* Nutzer um eine Entscheidung bitten willst.
* klare Antworten wie `Yes` und `No` anbieten willst.

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

* erstes `string`: der Titel des Dialogs
* zweites `string`: die Meldung im Dialog
* drittes `[string]`: die Antwortoptionen, die angezeigt werden sollen

`dialog()` gibt die ausgewählte Antwort als String zurück.

Das Skript wartet, bis der Nutzer eine Antwort auswählt.

#### Schauen wir uns einige Beispiele an:

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

Öffnet einen Bestätigungs-Dialog für eine Löschaktion.

```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
```

Löscht den aktuellen Datensatz nur, wenn der Nutzer bestätigt.

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

Fordert den Nutzer auf, die fragliche Eingabe noch einmal zu prüfen.

Tipps:

* `dialog()` läuft nur auf dem Client.
* Speichere das Ergebnis in einer Variable, wenn spätere Schritte davon abhängen.

## Häufige Muster für UI-Meldungen

Diese kurzen Muster zeigen typische Wege, Nutzer in einer App zu führen.

### Kurzes Erfolgsfeedback anzeigen

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

Zeigt direktes Feedback nach einer erfolgreichen Aktion an.

### Löschbestätigung abfragen

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

Fragt den Nutzer vor einer destruktiven Aktion.


---

# 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/de/automate-your-workflows/work-with-functions/user-interface.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.
