# Function: makeFormula()

> **makeFormula**\<`ParamDefsT`, `ResultT`, `SchemaT`>(`fullDefinition`): [`Formula`](../../type-aliases/Formula/)\<`ParamDefsT`, `ResultT`, `SchemaT`>

Defined in: [api.ts:1575](https://github.com/coda/packs-sdk/blob/b2b4c9dba5ca748bdbb94481cc13b5ca3c328ef6/api.ts#L1575)

Creates a formula definition.

You must indicate the kind of value that this formula returns (string, number, boolean, array, or object) using the `resultType` field.

Formulas always return basic types, but you may optionally give a type hint using `codaType` to tell Coda how to interpret a given value. For example, you can return a string that represents a date, but use `codaType: ValueType.Date` to tell Coda to interpret as a date in a document.

If your formula returns an object, you must provide a `schema` property that describes the structure of the object. See [makeObjectSchema](../makeObjectSchema/) for how to construct an object schema.

If your formula returns a list (array), you must provide an `items` property that describes what the elements of the array are. This could be a simple schema like `{type: ValueType.String}` indicating that the array elements are all just strings, or it could be an object schema created using [makeObjectSchema](../makeObjectSchema/) if the elements are objects.

## Type Parameters

| Type Parameter | Default type | | --- | --- | | `ParamDefsT` *extends* [`ParamDefs`](../../type-aliases/ParamDefs/) | - | | `ResultT` *extends* [`ValueType`](../../enumerations/ValueType/) | - | | `SchemaT` *extends* [`Schema`](../../type-aliases/Schema/) | [`Schema`](../../type-aliases/Schema/) |

## Parameters

| Parameter | Type | | --- | --- | | `fullDefinition` | [`FormulaDefinitionOptions`](../../type-aliases/FormulaDefinitionOptions/)\<`ParamDefsT`, `ResultT`, `SchemaT`> |

## Returns

[`Formula`](../../type-aliases/Formula/)\<`ParamDefsT`, `ResultT`, `SchemaT`>

## Examples

```
makeFormula({resultType: ValueType.String, name: 'Hello', ...});
```

```
makeFormula({resultType: ValueType.String, codaType: ValueType.Html, name: 'HelloHtml', ...});
```

```
makeFormula({resultType: ValueType.Array, items: {type: ValueType.String}, name: 'HelloStringArray', ...});
```

```
makeFormula({
  resultType: ValueType.Object,
  schema: makeObjectSchema({type: ValueType.Object, properties: {...}}),
  name: 'HelloObject',
  ...
});
```

```
makeFormula({
  resultType: ValueType.Array,
  items: makeObjectSchema({type: ValueType.Object, properties: {...}}),
  name: 'HelloObjectArray',
  ...
});
```
