# Javascript: CommentCollection.getNextItem Method

> Gets the next comment in the text flow.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: CommentCollection.getNextItem Method
- **387 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getnextitem-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getnextitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getnextitem-method/llms-full.txt

---

### Description

Gets the next comment in the text flow.

### Syntax

```javascript
<void> CommentCollection.getNextItem(<RequestCommentCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the comment. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `CommentCollection.getNextItem` in a practical document-editing workflow. It gets the next comment in the text flow.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const comments = mainText.comments;
    comments.getNextItem(
        function(comment) {
            if (!comment) {
                console.warn("No commented text was returned.");
                return;
            }
            
            console.log("get next item result:", comment);
        },
        onTxError
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: CommentCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getitem-method/llms-full.txt)
- **Next:** [Javascript: CommentCollection.getPreviousItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getpreviousitem-method/llms-full.txt)
