Skip to content
开发文档
能力中心
应用市场
WebOffice
开发者后台

Role.AddUser(方法)

说明

权限角色中添加协作者

添加协作者前要求文件开启分享,如果当前文档暂未开启分享,会添加失败提示Error: can't add user. FileNotShare

单次添加协作者的数量限制是20,超过20会失败并提示Adding more than the limit of collaborators at one time!

语法

表达式.AddUser(Users)

表达式:Role

参数

参数名是否必需类型描述
UsersDbUser权限角色中需要添加的协作者数组

返回值

User

浏览器环境示例

javascript
async function example() {
    await instance.ready();
    const app = instance.Application;
    const editRole = await app.Permission2.Roles(2);
    const users = [];
    const user1 = await app.User("283091702", "企业用户_283031898", "http://avatar.qwps.cn/avatar/5LyB5Lia55So5oi3XzI4MzAzMTg5OA==");
    users.push(user1);
    await editRole.AddUser(users);
}

脚本编辑器 示例

javascript
function main() {
    const users = [];
    const user1 = Application.User("283091702", "企业用户_283031898", "http://avatar.qwps.cn/avatar/5LyB5Lia55So5oi3XzI4MzAzMTg5OA==");
    users.push(user1);
    Application.Permission2.Roles.Item(2).AddUser(users);
}
main();