> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/budowanie-aplikacji/interfejs-uzytkownika/formularze/dynamicznosc-formularza/wstawki-javascript.md). Agents can also search and read this documentation through its [MCP server](https://docs.eximee.com/~gitbook/mcp).

# Wstawki JavaScript

## Obsługa dynamicznej treści (wstawki JavaScript)

System umożliwia wstawianie dynamicznej treści za pomocą wstawek JavaScript. Mogą one być używane w następujących miejscach:

* w komponentach **Treść formatowana (TextContent)**,
* w komponentach **Etykieta**,
* we właściwości **Etykieta** dostępnej w innych komponentach.

{% hint style="warning" %}
Funkcjonalność *nie obejmuje* komponentu **Treść formatowana (TextContent)** umieszczonego w obszarze **Footera**.
{% endhint %}

### Format wstawki JavaScript

Wstawki mają postać:

```js
<?js: return "wartość"; /** przykładowy kod JS zwracający wartość */ ?>
```

Treść wstawki musi zawsze zwracać wartość (np. string).

***

### Przykłady użycia

#### 1. Zwracanie wartości w zależności od pola formularza

Poniższa wstawka zwróci tekst *"m1. "* tylko wtedy, gdy pole o identyfikatorze `GesTextField1` zostało wypełnione:

```js
<?js: return getValue("GesTextField1") ? "m1. " : ""; ?>
```

***

#### 2. Obsługa wartości domyślnej i własnej (zmienne sesyjne)

W przykładzie poniżej, jeśli zmienna `etykietaWlasna` jest pusta lub ma wartość `null`, zostanie użyta wartość z `etykietaDomyslna`.\
Obie wartości są dostępne jako zmienne sesyjne:

```js
<?js: return (getValue("etykietaWlasna") == "" || getValue("etykietaWlasna") == null)
    ? "${etykietaDomyslna}"
    : "${etykietaWlasna}"; ?>
```

***

#### 3. Wstawka z formatowaniem HTML

W zależności od wartości pola `channel` dynamicznie zwracana jest treść zawierająca HTML:

```js
<?js:
  return getValue("channel") == "mobile"
    ? "<b>Zgoda na kontakt telefoniczny w celu marketingowym.</b> <span class='optional' style='color:#bec2c3;'>(opcjonalne)</span>"
    : "Zgoda na kontakt telefoniczny w celu marketingowym. <span class='optional' style='color:#bec2c3;'>(opcjonalne)</span>";
?>
```

***

### Dostępne metody JavaScript

W ramach wstawek można korzystać z metod opisanych w sekcji:

[**Język wyrażeń definiowania warunków**](https://docs.eximee.com/budowanie-aplikacji/logika-biznesowa/jezyk-wyrazen-definiowania-warunkow-warunki-z-getvalue.md)

Pozwala to m.in. na odwoływanie się do wartości pól, porównania, sprawdzanie pustych wartości itp.

***

### Ważna uwaga dotycząca identyfikatorów

W treści wstawek **nie poprzedzamy identyfikatorów komponentów ani nazw zmiennych symbolem `@`**.\
Przykład poprawny:

```js
getValue("GesTextField1")
```

Przykład niepoprawny:

```js
getValue("@GesTextField1")
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eximee.com/budowanie-aplikacji/interfejs-uzytkownika/formularze/dynamicznosc-formularza/wstawki-javascript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
