Javascript: CommentedText.getUserName Method
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
<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.
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);