# Javascript: TableOfContentsCollection.getItemByName Method

> Gets the table of contents with the specified name.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 29.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TableOfContentsCollection.getItemByName Method
- **436 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/getitembyname-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/getitembyname-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/getitembyname-method/llms-full.txt

---

### Description

Gets the table of contents with the specified name.

### Syntax

```javascript
<void> TableOfContentsCollection.getItemByName(<RequestTableOfContentsCallback> callback, [<ErrorCallback> errorCallback], <string> name)
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the requested table of contents or null if no table of contents with the specified name exists. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| name | The table of contents' name. |

### Examples

The following example demonstrates `TableOfContentsCollection.getItemByName` in a practical document-editing workflow. It gets the table of contents with the specified name.

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

function inspectItemByName(tableOfContentss) {
    tableOfContentss.getItemByName(
        function(toc) {
            if (!toc) {
                console.warn("No table of contents was returned.");
                return;
            }
            
            console.log("get item by name result:", toc);
        },
        onTxError,
        "QuarterlyReport"
    );
}
```

---

## Nearby

- **Previous:** [Javascript: TableOfContentsCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/getitem-method/llms-full.txt)
- **Next:** [Javascript: TableOfContentsCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/remove-method/llms-full.txt)
