> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doglytdc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a function

> Step by step to create a Dev panel function with a screen, menu item, connection and translations, with three complete examples.

A function is a folder in `painel-dev/funcoes/<id>/` with two files. The `<id>` is the folder name and also the address: `?tab=<id>`.

**1. Pick the id**

Lowercase, numbers and `-`, 2 to 32 characters, starting with a letter. It cannot be a built-in function id (`home`, `code`, `sales`…).

**2. Create funcao.json**

The menu item (`@nav`) and where the data comes from (`connect`).

**3. Create tela.html**

The layout, built with the [pieces](https://docs.doglytdc.dev/en/scripts/dev-panel/pieces.md).

**4. Add the texts**

Every new `@t.key` in all files of `traducoes/`.

**5. Validate and merge**

`dev_panel_validate` on the branch, then merge into main. Or use `dev_panel_function_create` in the MCP, which creates the folder and validates at once.

## funcao.json

| Field | Rule |
| - | - |
| `@nav.id` | Same as the folder name |
| `@nav.label` | Up to 40 characters or `@t.key` |
| `@nav.icon` | A name from the icon list |
| `@nav.position` | Integer from 1 to 999 |
| `@nav.group` | Optional. Without it, goes to **Panel functions** |
| `description` | Optional, up to 160 characters |
| `connect` | Required. See [Connections and actions](https://docs.doglytdc.dev/en/scripts/dev-panel/connections.md) |

Limit: **30 functions** per script.

## Example 1 — Notices (settings)

Edits fields of the script's remote configuration. The script reads these values in `window.DoglyScript.config`.

```json painel-dev/funcoes/avisos/funcao.json theme={null}
{
  "@nav": { "id": "avisos", "label": "@t.aviso.titulo", "icon": "megaphone", "position": 100 },
  "description": "Message shown to people using the script.",
  "connect": { "type": "config", "keys": ["aviso_ativo", "aviso_texto", "aviso_tipo", "aviso_cor"] }
}
```

```html painel-dev/funcoes/avisos/tela.html theme={null}
<section class="dt-stack">
  <h2>@t.aviso.titulo</h2>
  <p>@t.aviso.descricao</p>
  <dt-switch bind="aviso_ativo" label="@t.aviso.ativo" />
  <dt-textarea bind="aviso_texto" label="@t.aviso.texto" placeholder="@t.aviso.placeholder" />
  <dt-select bind="aviso_tipo" label="@t.aviso.tipo">
    <dt-option value="info" label="@t.aviso.tipo.info" />
    <dt-option value="alerta" label="@t.aviso.tipo.alerta" />
  </dt-select>
  <dt-color bind="aviso_cor" label="@t.aviso.cor" hint="@t.aviso.cor.dica" />
  <footer>
    <dt-button action="@reload" label="@t.comum.recarregar" tone="ghost" icon="refresh" />
    <dt-button action="@save" label="@t.comum.salvar" icon="check" />
  </footer>
</section>
```

Every `bind` must be in `connect.keys`. The panel only reads and saves those fields; the rest of the configuration is not touched.

## Example 2 — Coupons (server function)

Calls a server function of the script, which decides what to show and what each button does.

```json painel-dev/funcoes/cupons/funcao.json theme={null}
{
  "@nav": { "id": "cupons", "label": "@t.cupons.titulo", "icon": "ticket", "group": "People", "position": 45 },
  "description": "Creates and lists discount coupons.",
  "connect": { "type": "function", "name": "cupons" }
}
```

```html painel-dev/funcoes/cupons/tela.html theme={null}
<section class="dt-stack">
  <h2>@t.cupons.titulo</h2>
  <div class="dt-grid">
    <dt-stat bind="ativos" label="@t.cupons.ativos" icon="ticket" />
    <dt-stat bind="usos" label="@t.cupons.usos" icon="chart" />
  </div>
  <dt-text bind="codigo" label="@t.cupons.codigo" placeholder="WELCOME10" />
  <dt-select bind="tipo" label="@t.cupons.tipo" placeholder="@t.cupons.tipo.escolher">
    <dt-option value="pct" label="@t.cupons.tipo.pct" />
    <dt-option value="valor" label="@t.cupons.tipo.valor" />
  </dt-select>
  <dt-number bind="desconto" label="@t.cupons.desconto" min="1" max="100" step="1" />
  <dt-button action="@call:criar" label="@t.cupons.criar" icon="plus" />
  <hr />
  <dt-table bind="lista" columns="codigo,tipo,desconto,usos" empty="@t.cupons.vazio" />
</section>
```

What each button does is in [Connections and actions](https://docs.doglytdc.dev/en/scripts/dev-panel/connections.md#function-server-function).

## Example 3 — Report (collection, read-only)

Shows up to 100 records from a script collection. Collections are **read-only** in the Dev panel: only `dt-table`, `dt-stat` and `@reload`.

```json painel-dev/funcoes/relatorio/funcao.json theme={null}
{
  "@nav": { "id": "relatorio", "label": "@t.relatorio.titulo", "icon": "bar-chart", "position": 110 },
  "connect": { "type": "collection", "name": "acessos" }
}
```

```html painel-dev/funcoes/relatorio/tela.html theme={null}
<section class="dt-stack">
  <header>
    <h2>@t.relatorio.titulo</h2>
    <dt-button action="@reload" label="@t.comum.recarregar" tone="ghost" icon="refresh" />
  </header>
  <dt-alert tone="info">@t.relatorio.aviso</dt-alert>
  <dt-table bind="itens" columns="usuario,pagina,quando" empty="@t.relatorio.vazio" />
</section>
```

## The texts

```json painel-dev/traducoes/en.json theme={null}
{
  "@lang": "English",
  "aviso.titulo": "Notices",
  "aviso.descricao": "Message shown to people using the script.",
  "aviso.ativo": "Show notice",
  "aviso.texto": "Text",
  "aviso.placeholder": "E.g. New version available!",
  "aviso.tipo": "Type",
  "aviso.tipo.info": "Information",
  "aviso.tipo.alerta": "Alert",
  "aviso.cor": "Color",
  "aviso.cor.dica": "Color of the notice bar.",
  "comum.salvar": "Save",
  "comum.recarregar": "Reload",
  "cupons.titulo": "Coupons",
  "cupons.criar": "Create coupon",
  "relatorio.titulo": "Report"
}
```

Do the same in `pt-BR.json`, `es.json` and any extra languages. The **Translations** screen shows the missing keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.