# Javascript: DocumentTarget.getAutoGenerationType Method

> Gets the type of auto-generation. A document target which is the target of an entry in a table of contents is automatically generated when the table of contents is inserted into the document.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 29.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: DocumentTarget.getAutoGenerationType Method
- **511 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttarget/getautogenerationtype-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttarget/getautogenerationtype-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttarget/getautogenerationtype-method/llms-full.txt

---

### Description

Gets the type of auto-generation. A document target which is the target of an entry in a table of contents is automatically generated when the table of contents is inserted into the document.

### Syntax

```javascript
<void> DocumentTarget.getAutoGenerationType(<RequestNumberCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the document target's [auto generation type](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/autogenerationtype-enumeration/llms-full.txt). |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `DocumentTarget.getAutoGenerationType` in a practical document-editing workflow. It gets the type of auto-generation. A document target which is the target of an entry in a table of contents is automatically generated when the table of contents is inserted into the document.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentTargets = mainText.documentTargets;
    documentTargets.getItem(function(documentTarget) {
        if (!documentTarget) {
            console.warn("No document target is available at the current input position.");
            return;
        }
    
        documentTarget.getAutoGenerationType(
            function(result) {
                console.log("get auto generation type result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [DocumentTarget Object](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttarget/llms-full.txt)
- **Next:** [Javascript: DocumentTarget.getDeleteable Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttarget/getdeleteable-method/llms-full.txt)
