官方文档中似乎没有提及获取(或设置)谷歌文档中评论的受让人的方法。
是否有任何已知的方法,包括一些聪明的解决方法,以允许获取/推断 gdoc 中评论的受让人的姓名和/或电子邮件?
此解决方法列出了所有评论以及作者和受让人。但是,假设第一个“@email”将是受让人,因为目前 Drive API 中没有用于列出评论受让人的特定字段。
您可以使用下面的脚本作为创建您的脚本的基础。另外,请在服务选项卡中包含
Drive API v2
。
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].resolved; //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)
}
}