# Functions & Operators

The Digia Dashboard allows you to enrich your app’s behavior by adding custom expressions and logic directly from the UI. This can be done in any field that supports **dynamic values** — simply click on the **dynamic field icon** <mark style="color:orange;">\[<>]</mark> and the **Code Dialog** will open.

<figure><img src="https://3626461507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbhApDTL7kHrXte2TTtjs%2Fuploads%2Fgit-blob-b6f593cb52fe5229cd144c45228f1a9dcc55818f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Within this dialog, you can:

✅ **Use built-in expression functions**\
✅ **Nest expressions**\
✅ **Combine expressions with your own JavaScript functions**\
✅ **Generate expressions using AI**

<figure><img src="https://3626461507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbhApDTL7kHrXte2TTtjs%2Fuploads%2Fgit-blob-eeb48277c7eafed5ce34bf954c16d32cd6f25552%2Fimage.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

Preview Value is used for the Design mode and has no impact on the actual expression.

***

### 🤖 AI-Powered Expression Generation

Digia now supports AI-assisted expression writing. Simply write a prompt describing what the expression should do, hit generate, and the AI will create the expression for you. The generated expression is fully editable, allowing you to refine it as needed.

<figure><img src="https://3626461507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbhApDTL7kHrXte2TTtjs%2Fuploads%2Fgit-blob-9513d63abd04177f9e3e3130e98bcf6127eac17c%2Fexpr_ai.gif?alt=media" alt=""><figcaption><p>AI expression generation dialog</p></figcaption></figure>

This feature makes it easier for anyone to create complex expressions without deep knowledge of the syntax.

{% embed url="<https://youtu.be/-Szari3U080?si=qKr65i4R_XkbgvLw>" %}

***

### 🧠 Built-In Functions

Digia provides many built-in functions out of the box. These are grouped into the following categories:

| Category                                                                                       | Description                               |
| ---------------------------------------------------------------------------------------------- | ----------------------------------------- |
| [**JSON**](https://docs.digia.tech/logic-and-interaction/adding-logic/json-operators)          | Work with JSON objects and extract values |
| [**Math**](https://docs.digia.tech/logic-and-interaction/adding-logic/math-operators)          | Perform numeric calculations              |
| [**DateTime**](https://docs.digia.tech/logic-and-interaction/adding-logic/date-time-operators) | Parse, convert, and format dates          |
| [**String**](https://docs.digia.tech/logic-and-interaction/adding-logic/string-operations)     | Manipulate string values                  |
| [**Logical**](https://docs.digia.tech/logic-and-interaction/adding-logic/logical-operators)    | Add comparisons and logical operations    |

These functions can be mixed and matched in expressions and can also be **nested** within each other.

***

### 📌 Examples

| Expression                                     | Description                                             |
| ---------------------------------------------- | ------------------------------------------------------- |
| `jsonGet(response.data, 'users[0].id')`        | Returns the `id` of the first user in the list          |
| `isNotEqual(2, 2)`                             | Returns `false` because both arguments are equal        |
| `isoFormat('2024-06-03T23:42:36Z', 'Do MMMM')` | Converts ISO string into a readable format (`3rd June`) |

***

### 🔁 Nested Expressions

Expressions can reference other expressions:

```javascript
isNotEqual(
  jsonGet(response.data, 'users[0].id'),
  5
)
```

> In this example, the platform first resolves `jsonGet(...)`, and then evaluates the result against the number `5`.

***

### 🧩 [Custom JavaScript Functions](https://docs.digia.tech/logic-and-interaction/adding-logic/functions)

If the built-in expression language isn’t enough, you can write your own **JavaScript function** and call it from the code dialog.

Example:

```javascript
// Example in your functions
//Arguments are passed as an array
function calculateDiscount(args) {
  var price = args[0];
  return price * 0.8;
}
```

```javascript
// Called in Digia expression
js.eval('calculateDiscount', product.price)
```

***

### ✅ Summary

| Feature                          | Available |
| -------------------------------- | --------- |
| Built-in expression functions    | ✅         |
| Nested expressions               | ✅         |
| Custom JavaScript invocation     | ✅         |
| Combination of both              | ✅         |
| AI-powered expression generation | ✅         |
