# Code in Inputs

Use `${...}` for an expression and `$${...}` for a code block. Expressions insert their result. Code blocks run full code and must `return` a value to insert. All code runs locally on your device.

***

#### **Using `${...}` (expression)**

**Examples**

* "This is my secret password stored locally: ${`await zw.deviceStorage.get("password")`}"
* "This is my random number: ${`Math.random()`}"
* "This is my formatted input ${`"{id: 1234, name: Country Code}".trim().toUpperCase()`} \
  ⚠️ **Note**: table/variable references like `{id: 1234, name: Country Code}` are **not** code; they’re replaced with their values. If you need that value **as a string** inside code, wrap it in quotes (as above) or read it with `zw.getRef`: ${`(await zw.getRef({ ref_id: 1234, name: "Country Code" })).trim().toUpperCase()`}".

***

#### **Using `$${...}` (code block)**

**Examples:**

* "This is a value returned from an API: $${

  ```
  import axios from "axios"; // any import auto-installs locally
  const res = await axios.get("https://mydomain.com/my/api/url");
  return res.data;
  ```

&#x20;       }."

* "This is my input with more complex formatting: $${

  ```
  const fullAddress = await zw.getRef(ref_id: 1234, name: "Address" });
  const splitValues = fullAddress.split("country code: ");
  const countryCode = splitValues[1];

  if (!countryCode) {
    await zw.log({ message: "no country code", status: "warning" });
    return "unknown";
  }

  return countryCode.toUpperCase().trim();
  ```

  }."

***

<figure><img src="/files/Fc37E0prMkxKxrHfhjr1" alt=""><figcaption></figcaption></figure>


---

# 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.zerowork.io/using-zerowork/using-building-blocks/dynamic-inputs/code-in-inputs.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.
