我尝试了不同的方法但没有运气
var user = Session.getUser();
var userEmail = user.getEmail();
var viewers = someFolder.getViewers()
return (user in viewers)
也是这个
return (userEmail in viewers)
return (viewers.indexOf(userEmail) != -1)
这可能是微不足道的,但不适合我
谢谢,Fausto
答案 0 :(得分:1)
Folder.getViewers方法返回用户列表,您的代码搜索电子邮件,该电子邮件是作为对象的用户列表中的字符串。解决方案是
function testUser() {
var bUserFound = false;
var user = Session.getUser();
var userEmail = user.getEmail();
var viewers = someFolder.getViewers();
for (var i = 0; i < viewers.length; i++) {
var viewer = viewers[i];
if (viewer.getEmail() == userEmail) {
bUserFound = true;
break;
}
}
return bUserFound;
}