# Javascript: CommentedText.getUserName Method

> Gets the name of the user who has commented the document. This parameter can be null or an empty string to indicate that an unknown user has made the comment.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: CommentedText.getUserName Method
- **461 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/commentedtext/getusername-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/commentedtext/getusername-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/commentedtext/getusername-method/llms-full.txt

---

### Description

Gets the name of the user who has commented the document. This parameter can be null or an empty string to indicate that an unknown user has made the comment.

### Syntax

```javascript
<void> CommentedText.getUserName(<RequestStringCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

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

### Examples

The following example demonstrates `CommentedText.getUserName` in a practical document-editing workflow. It gets the name of the user who has commented the document. This parameter can be null or an empty string to indicate that an unknown user has made the comment.

```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.getItem(function(commentedText) {
        if (!commentedText) {
            console.warn("No commented text is available at the current input position.");
            return;
        }
    
        commentedText.getUserName(
            function(result) {
                console.log("get user name result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: CommentedText.getText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/commentedtext/gettext-method/llms-full.txt)
- **Next:** [Javascript: CommentedText.scrollTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/commentedtext/scrollto-method/llms-full.txt)
