Skip to main content

AddComment

Adds a comment to the specifed document element or array of Runs.

Syntax

expression.AddComment(element, text, author, userId);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
elementRequiredApiRun[] | DocumentElementThe element where the comment will be added. It may be applied to any element which has the AddComment method.
textRequiredstringThe comment text.
authorOptionalstringThe author's name.
userIdOptionalstringThe user ID of the comment author.

Returns

ApiComment

Example

This example adds text and comment to the first paragraph.

// How to add a comment to the ApiParagraph class.

// How to comment on text.

// Adds a paragraph to the document and comments on it.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
Api.AddComment(paragraph, "ONLYOFFICE for developers", "Jane");