Context
Overview
Context-related functions. Context represents environment parameters during execution
userId
Returns the current operating user ID
Context.userId()Return Value
Type String Current operating user
Examples
Context.userId() //ek5veueb6c9zgTip
Context user only has a value when the operation is initiated by a user, for example, when in scheduled task execution or API access, the operating user is null
appId
Returns the current application ID
Context.appId()Return Value
Type String Current application ID
Examples
Context.appId()appEnvProp
Returns the environment variable of the current application
Context.appEnvProp(propKey)| Parameter | Type | Description |
|---|---|---|
| propKey | String | Environment variable key |
Return Value
Type String Environment variable value
Examples
Assume the environment variables set in the application are as follows
| Environment | Variable Identifier | Variable Value |
|---|---|---|
| dev | payURL | http://dev-demo.com/pay |
| prd | payURL | http://prd-demo.com/pay |
//When called in dev environment
Context.appEnvProp('payURL')//http://dev-demo.com/payNote
When used on the client side, only environment variables set to allow client-side access can be accessed. The server side has no such restriction
httpHeaders
Returns the http header of the current operation
Context.httpHeaders()Return Value
Type Object http header values
Examples
TIP
If the operation is not triggered by a user (e.g., scheduled task, event handler), httpHeaders returns {}
clipboardType
Returns the data type stored in the current application clipboard
Context.clipboardType()Return Value
Type String Data type stored in the application clipboard
Examples
Context.clipboardType() //testThe application clipboard needs to be set through the following operations
- Automation step
Set Application Clipboard - Control
Set Application Clipboard Data
clipboardData
Returns the data stored in the current application clipboard
Context.clipboardData()Return Value
Type Object Data stored in the application clipboard
weworkAccessToken
Returns WeChat Work AccessToken
Context.weworkAccessToken()Return Value
Type String WeChat Work AccessToken
dingtalkAccessToken
Returns DingTalk AccessToken
Context.dingtalkAccessToken()Return Value
Type String DingTalk AccessToken
feishuAccessToken
Returns Feishu Application AccessToken
Context.feishuAccessToken()Return Value
Type String Feishu Application AccessToken
feishuTenantAccessToken
Returns Feishu Tenant AccessToken
Context.feishuTenantAccessToken()requestIp
Returns the current request's IP information
Context.requestIp()Return Value
Type String Returns the current request's IP information
hasAppPerm
Checks if the current user has application permission with identifier permKey
Context.hasAppPerm(permKey)| Parameter | Type | Description |
|---|---|---|
| permKey | String | Permission identifier |
Return Value
Type Boolean Whether the user has the application permission
hasModulePerm
Checks if the current user has module permission with module identifier moduleKey and permission identifier permKey
Context.hasModulePerm(moduleKey, permKey);| Parameter | Type | Description |
|---|---|---|
| moduleKey | String | Module identifier |
| permKey | String | Permission identifier |
Return Value
Type Boolean Whether the user has the module permission

