跳到主要内容

GetUserId

返回批注作者的用户 ID。

语法

expression.GetUserId();

expression - 表示 ApiComment 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

检索文档中批注作者的用户 ID。

// How do I get the identifier of the user who posted a comment in a document?

// Match a comment to a user account by reading the author's unique user ID.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is just a sample text");
Api.AddComment(paragraph, "comment", "John Smith");
let comments = doc.GetAllComments();
comments[0].SetUserId("uid-1");
let userId = comments[0].GetUserId();
paragraph = Api.CreateParagraph();
paragraph.AddText("Comment user ID: " + userId);
doc.Push(paragraph);