跳到主要内容

实用工具 - 获取登录人员信息

1. 使用场景

本例介绍如何在宜搭中通过不同的方式获取登录人员信息。

2. 实现功能

2.1. 通过公式获取

{
"corpId": "登录人 corpId",
"label": "登录人姓名",
"avatar": "头像地址",
"key": "登录人 userId",
"businessWorkNo": "登录人工号"
}

2.1.1. 成员(成员组件)

{"text":"USER()","marks":[],"isCmData":true}

2.1.2. 员工姓名 label(单行文本组件)

{"text":"GetObjectField(GetArrayItem(UserBuilder(​成员​),1),\"label\")","marks":[{"from":{"line":0,"ch":40,"sticky":null},"to":{"line":0,"ch":44,"sticky":null},"value":"employeeField_lbeuamvz","invalid":false}],"isCmData":true}

2.1.3. 头像图片地址 avatar(单行文本组件)

{"text":"GetObjectField(GetArrayItem(UserBuilder(​成员​),1),\"avatar\")","marks":[{"from":{"line":0,"ch":40,"sticky":null},"to":{"line":0,"ch":44,"sticky":null},"value":"employeeField_lbeuamvz","invalid":false}],"isCmData":true}

2.1.4. 所属组织 corpId(单行文本组件)

{"text":"GetObjectField(GetArrayItem(UserBuilder(​成员​),1),\"corpId\")","marks":[{"from":{"line":0,"ch":40,"sticky":null},"to":{"line":0,"ch":44,"sticky":null},"value":"employeeField_lbeuamvz","invalid":false}],"isCmData":true}

2.1.5. 员工工号 businessWorkNo(单行文本组件)

{"text":"GetObjectField(GetArrayItem(UserBuilder(​成员​),1),\"businessWorkNo\")","marks":[{"from":{"line":0,"ch":40,"sticky":null},"to":{"line":0,"ch":44,"sticky":null},"value":"employeeField_lbeuamvz","invalid":false}],"isCmData":true}

2.1.6. 员工 userId(单行文本组件)

{"text":"GetObjectField(GetArrayItem(UserBuilder(​成员​),1),\"key\")","marks":[{"from":{"line":0,"ch":40,"sticky":null},"to":{"line":0,"ch":44,"sticky":null},"value":"employeeField_lbeuamvz","invalid":false}],"isCmData":true}

2.2. 通过宜搭 JSAPI 获取

window.loginUser;

2.2.1. 员工姓名 userName(单行文本组件)

utils.getLoginUserName()

2.2.2. 员工 userId(单行文本组件)

utils.getLoginUserId()

2.2.3. 头像图片地址 avatar(单行文本组件)

window.loginUser.avatar

2.2.4. 员工工号 businessWorkNo(单行文本组件)

window.loginUser.businessWorkNo

2.2.5. 所属部门名称 deptName

window.loginUser.deptName

2.2.6. 所属部门id deptId

window.loginUser.deptId

3. 实现效果

3.1. 通过公式获取

3.2. 通过宜搭 JSAPI 获取

4. 在线试玩

Copyright © 2024钉钉(中国)信息技术有限公司和/或其关联公司浙ICP备18037475号-4