# Javascript: DocumentTarget.setID Method

> Sets an identifier for the document target.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: DocumentTarget.setID Method
- **455 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/documenttarget/setid-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/documenttarget/setid-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/documenttarget/setid-method/llms-full.txt

---

### Description

Sets an identifier for the document target.

### Syntax

```javascript
<void> DocumentTarget.setID(<number> id, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| id | An identifier for the document target. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `DocumentTarget.setID` in a practical document-editing workflow. It sets an identifier for the document target.

```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.setID(
            25,
            function() {
                console.log("set id completed.");
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: DocumentTarget.setDeleteable Method](https://docs.textcontrol.com/ds-server/reference/javascript/documenttarget/setdeleteable-method/llms-full.txt)
- **Next:** [Javascript: DocumentTarget.setName Method](https://docs.textcontrol.com/ds-server/reference/javascript/documenttarget/setname-method/llms-full.txt)
