# Formula Field API

| **Formula field**                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------- |
| *\<formula name=”string” placeholder=”string” search=”boolean” precision=”integer” formatting=”boolean” trailingZeros=”boolean”>value\</formula>* |

Formula is read-only field with the value calculated using EXCEL operations.

#### Formula Field attributes

* **name** — string, length from 1 up to 128 symbols, restricted symbols &, “, <, >, field name used to fill in on envelope, unique for document, mandatory attribute.
* **placeholder** — field placeholder displayable on template and envelope, length from 0 up to 1024 symbols, if empty on envelope will be displayed field name, optional attribute.
* **search** — boolean, defines if field is searchable on envelope search or not, if not set default value false, optional attribute.
* **precision** — integer, defines quantity of decimal numbers allowed, allowed value range from 0 to 7, default value 2, optional attribute.
* **formatting** — boolean, defines conversion of field data to on UI to local format set up in User profile, optional attribute.
* **trailingZeros** — boolean, defines how to show decimal zeros after field completion, available only with precision value, optional attribute.
* **value** — is a formula with only one operation.

SUPPORTED OPERATIONS: SUM, PRODUCT, SUBTRACT, DIVIDE, COUNTA, MAX, MIN

#### Example 1

SUM({field1},{doc2::field2}) where

* {field1} is a value of field1 from the same document.
* {doc2::field2} is a value of field2 in document with id ‘doc2’.

#### Example 2

formula SUM({field1}) next to dynamic table where

* {field1} ia a field name from the table.
* All values from all rows will summed up.


---

# 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://support.docstudio.com/docstudio-docs/docstudio-for-developers/api-documentation/template-api/template-dynamic-fields-api/formula-field-api.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.
