在谷歌文档中如何获取评论的受托人?

huangapple go评论63阅读模式
英文:

How to get the assignee of a comment in Google Docs?

问题

official documentation of a method to get (or set) the assignee of a comment in a google doc.

有没有已知的方法,包括可能的巧妙解决方法,允许获取/推断 gdoc 中评论的受让人的姓名和/或电子邮件?

英文:

There seems to be no mention in the official documentation of a method to get (or set) the assignee of a comment in a google doc.

Is there any known way, including perhaps some clever workaround, to allow getting/inferring the name and/or email of the assignee of a comment in a gdoc?

答案1

得分: 1

短答案:目前暂无此功能。


目前无法获取评论的受让人。根据当前的Google Drive API文档,您只能访问评论的作者、状态、内容、ID等信息。没有字段可用于获取评论的受让人。您可以通过Google的问题跟踪器提出功能请求。

解决方法:使用Drive API v2


此解决方法列出了所有评论以及作者和受让人。然而,假定第一个“@email”将成为受让人,因为目前在Drive API中没有专门用于列出评论受让人的字段。

脚本:


您可以将以下脚本用作创建您自己脚本的基础。同时,请在服务选项卡中包括“Drive API v2”。

function getAssignee() {
  var fields = Drive.Comments.list("文件ID",{ fields: "*" }); // 在此处插入文件ID
  var commentsQty = fields.items.length;
  for (let i = 0; i < commentsQty; i++) {
    var commentAuthor = fields.items[i].author.displayName; // 获取评论作者
    var contentValue = fields.items[i].content; // 获取评论内容
    var commentResolve = fields.items[i].status; // 检查评论是否已解决
    var assignee = contentValue.match(/@[^\s]+/g); // 提取受让人,假定第一个 @email 地址是受让人
    console.log("评论作者:", commentAuthor, "\n受让人:", assignee[0], "\n状态:", commentResolve ? "已解决" : "未解决", "\n评论:", contentValue);
  }
}

输出:

在谷歌文档中如何获取评论的受托人?

参考:

英文:

Short Answer: There is no such feature at the moment

Getting the assignee of a comment is not available at the moment. As far as the current Google Drive API documentation goes, you can only access the comment's author, status, content, ID, etc. There are no fields for getting the comment assignee. You may request a feature request through Google's Issue Tracker.

Workaround: Use Drive API v2

This workaround lists all of the comments as well as the author and assignee. However, an assumption that the first &quot;@email&quot; will be the assignee is in place since there are no specific fields in the Drive API for listing comment assignee as of the moment.

Script

You may use the script below as a basis for creating yours. Also, please include Drive API v2 in the services tab.

function getAssignee() {
  var fields = Drive.Comments.list(&quot;FILE ID&quot;,{ fields: &quot;*&quot; }); //Insert file ID here
  var commentsQty = fields.items.length;
  for (let i = 0; i &lt;commentsQty; i++) {
    var commentAuthor = fields.items[i].author.displayName; //gets the comment author
    var contentValue = fields.items[i].content; //gets the comment content
    var commentResolve = fields.items[i].status; //Checks if the comment is resolved
    var assignee = contentValue.match(/@[^\s]+/g); //extract the assignee assuming that the first @emailaddress is the assignee
    console.log(&quot;Comment Author: &quot;,commentAuthor,&quot;\nAssignee:&quot;,assignee[0],&quot;\nStatus:&quot;,commentResolve?&quot;Resolved&quot;:&quot;Not Yet Resolved&quot;,&quot;\nComment: &quot;,contentValue)
  }
}

Output:

在谷歌文档中如何获取评论的受托人?

References:

huangapple
  • 本文由 发表于 2023年4月4日 04:32:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923552.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定