# Examples

### Basic Transformations

**UseCase 1:** Navigates through a nested JSON response to find a specific customer's last name and converts the text to all capital letters.

```
{{3.response.customers.0.last_name.toUpper()}} 
```

**UseCase 2:** Demonstrates chaining multiple string functions where each transformation is applied to the result of the previous one.

```
{{3.response.customers.0.last_name.toUpper().toLower().toTitleCase()}} 
```

### Dynamic and Nested Transformations

**UseCase 1:** Retrieves a value from expression 3 to use as a key. It then looks up that dynamic key inside object 2 and accesses the "foo" property within that result.

```
{{2.{{3.name}}.foo}} 
```

**UseCase 2:** Executes a search-and-replace where both the search term and the replacement term are processed by functions before being passed into the parent replace function. The inner expressions are executed first, and the values are passed as arguments to the main expression.

{% code overflow="wrap" %}

```
{{3.response.customers.0.default_address.name.replace({{3.response.customers.0.last_name.toLower()}}, {{3.response.customers.0.first_name.toUpper()}})}} 
```

{% endcode %}

**UseCase 3:** Resolves a dynamic key from expression 3 to find a value, then performs a replacement using another dynamic value from expression 4 as the search target.

```
{{variables.customer_data.{{3.key}}.value.replace({{4.x}},'z')}}
```

### Logical and List Transformations

**UseCase 1:** Converts a raw string stored in variable 21 into a structured JSON object, then extracts the value associated with the "name" property.

```
{{21.parseJSON().name}} 
```

**UseCase 2:** Combines the current settings object with a default settings object (overwriting where necessary) and then discards all keys except for 'theme' and 'lang'.

```
{{4.payload.settings.merge({{5.defaults}}).pick(['theme', 'lang'])}} 
```

**UseCase 3:** Scans a list for active users, extracts only their email fields, and joins them into a single semicolon-separated string.

```
{{2.users.filter("element.active == true").pluck('email').join('; ')}} 
```

### Error Handling and Fallback Option

**UseCase 1:** Attempts a calculation; if the field "name" is missing or is not a number, the entire operation safely returns the numeric value 0.

```
{{3.response.name.add(10).increment().fallback(0)}}
```

**UseCase 2:** Demonstrates error skipping. Because add("Guna") fails, the engine skips all keys and functions until the next fallback (.toString().add(2).toUpper() are ignored). It then continues execution from fallback(1) into the .increment() function.

```
{{3.response.customers.3.orders_count.add("Guna").toString().add(2).toUpper().fallback(1).increment().fallback(10)}} 
```

**UseCase 3:** Uses a fallback within an inner expression. If the dynamic "age" value is missing, it defaults to 10 for the addition. If the primary "orders\_count" path is broken, the outer fallback returns 100.

```
{{3.response.customers.0.orders_count.add({{78.age.fallback(10)}}).fallback(100)}} 
```


---

# 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.dckapintegrator.com/project-manager/workflows/inline-transformations/examples.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.
