# WorkbookCalculation.registerFunction Method

> WorkbookCalculation.registerFunction method in the TX Sheet Control JavaScript API for Node.js: Registers a callback, including Promise results.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > JavaScript API > Node.js Server > WorkbookCalculation > WorkbookCalculation.registerFunction Method
- **520 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/registerfunction-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/registerfunction-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/registerfunction-method/llms-full.txt

---

Registers a callback, including Promise results. Registration changes invalidate all formula caches.

Owner: [WorkbookCalculation](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/llms-full.txt). Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

### Syntax

```javascript
owner.registerFunction(name, definition)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `name` | `string` | No | Name validated in the owning collection or document scope. |
| `definition` | `CustomFunctionDefinition` | No | Value matching definition's declared type and the owning object's validation rules. |

### Return Value

`void`.

### Examples

Use a fresh sample workbook for this example. In the browser pass editor.workbook; in Node.js pass the server control. Document-bound objects are obtained from that same owner.

```javascript
function registerInvoiceFunction(control) {
    const book = control.workbook;
    book.calculation.registerFunction('DOUBLE', {
        minArguments: 1,
        maxArguments: 1,
        evaluate: ([value]) => (typeof value === 'number' ? value * 2 : 0),
    });

    book.sheets.at(0).cell('B10').setFormula('=DOUBLE(120)');
}
```

### Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

### See Also

- [WorkbookCalculation Class](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/llms-full.txt)
- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [CustomFunctionDefinition Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/customfunctiondefinition/llms-full.txt)

---

## Nearby

- **Previous:** [WorkbookCalculation.recalculateAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/recalculateasync-method/llms-full.txt)
- **Next:** [WorkbookCalculation.removeFunction Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/workbookcalculation/removefunction-method/llms-full.txt)
