英文:
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 "@email" 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("FILE ID",{ fields: "*" }); //Insert file ID here
var commentsQty = fields.items.length;
for (let i = 0; i <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("Comment Author: ",commentAuthor,"\nAssignee:",assignee[0],"\nStatus:",commentResolve?"Resolved":"Not Yet Resolved","\nComment: ",contentValue)
}
}
Output:
References:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论