# Javascript: SubTextPart.getID Method

> Gets an identifier for a subtextpart.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: SubTextPart.getID Method
- **417 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/subtextpart/getid-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/subtextpart/getid-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/subtextpart/getid-method/llms-full.txt

---

### Description

Gets an identifier for a subtextpart.

### Syntax

```javascript
<void> SubTextPart.getID(<RequestNumberCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | The callback function that receives the requested value. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `SubTextPart.getID` in a practical document-editing workflow. It gets an identifier for a subtextpart.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const subTextParts = mainText.subTextParts;
    subTextParts.getItem(function(subTextPart) {
        if (!subTextPart) {
            console.warn("No sub text part is available at the current input position.");
            return;
        }
    
        subTextPart.getID(
            function(result) {
                console.log("get id result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: SubTextPart.getHighlightMode Method](https://docs.textcontrol.com/ds-server/reference/javascript/subtextpart/gethighlightmode-method/llms-full.txt)
- **Next:** [Javascript: SubTextPart.getLength Method](https://docs.textcontrol.com/ds-server/reference/javascript/subtextpart/getlength-method/llms-full.txt)
