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

# Session functions

> Read the current database, table, record, user, role, browser class, and URL.

Session functions use the snapshot supplied by the current Dsync screen or workflow. They are useful for client-facing routing and labels, but they do not replace server-side access control.

## `AppId`

Returns the ID of the current TeamDesk database.

* **Syntax:** `AppId()`
* **Requires:** an active session snapshot.
* **Returns:** Text.
* **Best for:** integration payloads and database-aware links.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
AppId()
```

## `BackURL`

Returns the back-navigation URL supplied by the current screen or workflow.

* **Syntax:** `BackURL()`
* **Requires:** an active session snapshot with back-navigation information.
* **Returns:** Text URL.
* **Best for:** return links after a client action.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
BackURL()
```

## `Browser`

Returns the current client device class.

* **Syntax:** `Browser()`
* **Requires:** an active session snapshot.
* **Returns:** Text: `Desktop`, `Tablet`, `Mobile`, or `TV`.
* **Best for:** presentation choices and client-side routing hints.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Browser()
```

Do not use browser class as an authentication or authorisation check.

## `ColumnId`

Returns the unique ID mapped to a column.

* **Syntax:** `ColumnId([Column])` or `ColumnId("Column Name")`
* **Requires:** an active session snapshot containing column identities.
* **Returns:** Text ID, or empty text when the column is not mapped.
* **Best for:** metadata and integrations that address columns by stable ID.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ColumnId([Status])
```

## `Exists`

Checks whether a selected reference record exists and is accessible in the current session.

* **Syntax:** `Exists(referenceName)`
* **Requires:** Text identifying a reference present in the session snapshot.
* **Returns:** Boolean.
* **Best for:** guarding client presentation or workflow steps that depend on a related record.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Exists("Parent")
```

## `IsUserEmail`

Checks whether an email belongs to a known database user.

* **Syntax:** `IsUserEmail(email)`
* **Requires:** Text email and an active session user directory.
* **Returns:** Boolean.
* **Best for:** validating user selections and assignment inputs.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IsUserEmail([Assignee Email])
```

## `RecordId`

Returns the internal ID of the current record.

* **Syntax:** `RecordId()`
* **Requires:** an active record session snapshot.
* **Returns:** Text.
* **Best for:** deep links, integration correlation, and record labels.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
RecordId()
```

## `Role`

Returns the current user's role or the role attached to another User value.

* **Syntax:** `Role()` or `Role(user)`
* **Requires:** an active session; the optional argument must be a User value.
* **Returns:** Text role name, or empty text when the supplied user has no role.
* **Best for:** role-aware client presentation and workflow defaults.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Role()
Role([Assigned User])
```

<Warning>
  Use server-side permissions for access control. A formula result is not an authorisation boundary.
</Warning>

## `TableId`

Returns the ID of the current table.

* **Syntax:** `TableId()`
* **Requires:** an active session snapshot.
* **Returns:** Text.
* **Best for:** integration payloads and table-aware links.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
TableId()
```

## `ToUser`

Looks up a User value by email.

* **Syntax:** `ToUser(email)`
* **Requires:** Text email and an active session user directory.
* **Returns:** User, or `null` when no user matches.
* **Best for:** turning imported or entered email addresses into assignable users.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToUser([Assignee Email])
```

Email matching ignores case.

## `URL`

Returns the full URL of the current page.

* **Syntax:** `URL()`
* **Requires:** an active session snapshot with page URL information.
* **Returns:** Text URL.
* **Best for:** share links and integration context.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
URL()
```

## `URLRoot`

Returns the protocol and site portion used to access TeamDesk.

* **Syntax:** `URLRoot()`
* **Requires:** an active session snapshot with URL-root information.
* **Returns:** Text URL root.
* **Best for:** building stable links to other pages in the same site.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Concat(URLRoot(), "/some/path")
```

## `User`

Returns the user currently accessing the database.

* **Syntax:** `User()`
* **Requires:** an active session snapshot.
* **Returns:** User.
* **Best for:** defaults, attribution, and user-specific presentation.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
User()
```

## `UserToEmail`

Returns the email address stored on a User value.

* **Syntax:** `UserToEmail(user)`
* **Requires:** a User value.
* **Returns:** Text email.
* **Best for:** messages and integration payloads.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
UserToEmail(User())
```

## `UserToName`

Returns the display name stored on a User value.

* **Syntax:** `UserToName(user[, format])`
* **Requires:** a User value and optional `"FF"` or `"LF"` format. `FF` is the default display order; `LF` converts a multi-part name to last-name-first when possible.
* **Returns:** Text name.
* **Best for:** greetings, assignments, print output, and sorted labels.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
UserToName(User())
UserToName([Assigned User], "LF")
```

<Tip>
  Keep a person as a User value while making assignments. Convert to name or email only when displaying or exporting it.
</Tip>
