# Javascript: TXTextControl.beginUndoAction Method

> Begins a user-defined undo operation. All editing and fomatting changes made between beginUndoAction and endUndoAction belong to the undo operation. These changes are undone or redone in a single step. The specified user-defined name is available via getUndoActionName.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TXTextControl.beginUndoAction Method
- **459 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/beginundoaction-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/beginundoaction-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/beginundoaction-method/llms-full.txt

---

### Description

Begins a user-defined undo operation. All editing and fomatting changes made between beginUndoAction and [endUndoAction](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/endundoaction-method/llms-full.txt) belong to the undo operation. These changes are undone or redone in a single step. The specified user-defined name is available via [getUndoActionName](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/getundoactionname-method/llms-full.txt).

### Syntax

```javascript
<void> TXTextControl.beginUndoAction(<string> actionName, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| actionName | Specifies the undo action's name. If an action name is not necessary, this parameter can be null or an empty string. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TXTextControl.beginUndoAction` in a practical document-editing workflow. Begins a user-defined undo operation. All editing and fomatting changes made between beginUndoAction and endUndoAction belong to the undo operation. These changes are undone or redone in a single step. The specified user-defined name is available via getUndoActionName.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.beginUndoAction(
    "QuarterlyReport",
    function() {
        console.log("begin undo action completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: TXTextControl.barcodeTypeSettings Property](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/barcodetypesettings-property/llms-full.txt)
- **Next:** [Javascript: TXTextControl.BreakType Enumeration](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/breaktype-enumeration/llms-full.txt)
