informat.system System Global Operations
Overview
Use the informat.system object to perform global operations on the system. Global operations require the System Function Call module to be included in the license.
serverId
Query server node ID
informat.system.serverId();Return Value Type: String Returns the server node ID.
The server node ID value is from the informat-next/instance/informat-xxxx/application.yml file, under the spring > application > serverId configuration item.
Example
informat.system.serverId(); // informat2-biz-prdhost
Return the system's home page address
informat.system.host();Return Value Type: String Returns the system's home page address.
Example
informat.system.host();
// Returns
https://next.informat.cn/getAccount
Query account information
informat.system.getAccount(id);| Parameter | Type | Description |
|---|---|---|
| id | String | Account ID |
Return Value Type: Account Returns the account information. If the account does not exist, null is returned.
Example
Assuming that the system has an account with ID lwfwqr67xsvup and the user is named mr.zhang
informat.system.getAccount("lwfwqr67xsvup");Return Value
{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr.zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
}getAccountByUserName
Query account information by username
informat.system.getAccountByUserName(userName);| Parameter | Type | Description |
|---|---|---|
| userName | String | Username |
Return Value Type: Account Returns the account information. If the account does not exist, null is returned.
Example
Assuming that the system has a user named mr.zhang with the username zhangsan
informat.system.getAccountByUserName("zhangsan");Return Value
{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr.zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
}getAccountByMobileNo
Query account information by mobile number
informat.system.getAccountByMobileNo(mobileNo);| Parameter | Type | Description |
|---|---|---|
| mobileNo | String | Mobile number |
Return Value Type: Account Returns the account information. If the account does not exist, null is returned.
Example
Assuming that the system has a user named mr.zhang with the mobile number 13012345678
informat.system.getAccountByMobileNo("13012345678");Return Value
{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr.zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
}getAccountByEmail
Query account information by email address
informat.system.getAccountByEmail(email);| Parameter | Type | Description |
|---|---|---|
String | Email address |
Return Value Type: Account Returns the account information. If the account does not exist, null is returned.
Example
Assuming that the system has a user named mr.zhang with the email address zhangsan@example.com
informat.system.getAccountByEmail("zhangsan@example.com");Return Value
{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr.zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
}queryAccountList
Query account list
informat.system.queryAccountList(query);| Parameter | Type | Description |
|---|---|---|
| query | Query | Account query conditions |
Return Value Type: Array [Account](/guide/script/model.md#account) Returns the account list. If no account is found, an empty array is returned.
| Field | Type | Description |
|---|---|---|
| id | String | Account ID |
| name | String | Name |
| userName | String | Username |
| mobileNo | String | Mobile number |
String | Email address | |
| oid | String | Third-party ID |
Return Value Type: Array [Account](/guide/script/model.md#account) Returns the account list. If no account is found, an empty array is returned.
Example
informat.system.queryAccountList({
pageIndex: 1,
pageSize: 10,
filter: {
conditionList: [
{
fieldId: "userName",
opt: "contains",
value: "zhang",
},
],
},
});Return Value
[
{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr.zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
},
{
"avatar": "pic23.png",
"createTime": 1675836165076,
"id": "x3q3npo3xsait",
"isValid": true,
"mobileNo": "18291909205",
"name": "mr.zhang",
"updateTime": 1683594979000,
"userName": "zhangrongli",
"valid": true
},
{
"avatar": "pic13.png",
"createTime": 1682307631474,
"email": "zhangrongfu@itit.io",
"id": "wlt9cgr70o0yi",
"isValid": true,
"mobileNo": "15989268009",
"name": "mr.zhang",
"updateTime": 1683335991000,
"userName": "zhangrongfu",
"valid": true
}
]queryAccountListCount
Query account list total count
informat.system.queryAccountListCount(filter);| Parameter | Type | Description |
|---|---|---|
| filter | Filter | Account query conditions |
Return Value Type: Integer Returns the total number of accounts that match the query conditions. If no account is found, 0 is returned.
Example
informat.system.queryAccountListCount({
conditionList: [
{
fieldId: "userName",
opt: "contains",
value: "zhang",
},
],
}); // Returns 3addAccount
Add account
informat.system.addAccount(account);| Parameter | Type | Description |
|---|---|---|
| account | Account | Account information, ID and creation time are not required |
Return Value Type: String Returns the ID of the newly added account.
Example 1 Add Account
informat.system.addAccount({
name: 'test',
avatar: 'pic15.png',
userName: 'test',
mobileNo: '13800000000',
email: 'test@informat.cn',
password: 'youpassword'
});"ap1cew2up9ehq"Example 2 Add Account with Specified ID
informat.system.addAccount({
id: 'zhangsan',
name: 'test',
avatar: 'pic15.png',
userName: 'zhangsan',
mobileNo: '13800000000',
email: 'zhangsan@informat.cn',
password: 'youpassword'
});"zhangsan"updateAccount
Update account information
informat.system.updateAccount(account);| Parameter | Type | Description |
|---|---|---|
| account | Account | Account information |
Can update the following fields:
| Field | Type | Description |
|---|---|---|
| oid | String | Identifier |
| name | String | Name |
| userName | String | Username |
| mobileNo | String | Mobile number |
| String | Email address | |
| avatar | String | Avatar image |
| language | String | Language |
| needUpdatePassword | Boolean | Whether to force password update |
Return Value Type: Integer Returns the number of accounts updated. If no account is found, 0 is returned.
Example 1 Update Account
informat.system.updateAccount({
id: 'ap1cew2up9ehq',
name: 'test2',
avatar: 'pic16.png',
userName: 'test2',
mobileNo: '13700000000',
email: 'test2@informat.cn'
});1updateAccountList
Update account list
informat.system.updateAccountList(account, filter);| Parameter | Type | Description |
|---|---|---|
| account | Account | Account information |
| filter | Filter | Account query conditions |
Can update the following fields:
| Field | Type | Description |
|---|---|---|
| oid | String | Identifier |
| name | String | Name |
| userName | String | Username |
| mobileNo | String | Mobile number |
| String | Email address | |
| avatar | String | Avatar image |
| language | String | Language |
| needUpdatePassword | Boolean | Whether to force password update |
Return Value Type: Integer Returns the number of accounts updated. If no account is found, 0 is returned.
Example 1 Update Account List
informat.system.updateAccountList(
{
name: 'test2',
avatar: 'pic15.png',
userName: 'test2',
mobileNo: '13900000000',
email: 'test2@informat.cn'
},
{
conditionList: [
{ 'fieldId': 'id', 'opt': 'eq', 'value': 'ap1cew2up9ehq' }
]
}
);1changePassword
Change account password
informat.system.changePassword(accountId, pwd);| Parameter | Type | Description |
|---|---|---|
| accountId | String | Account ID |
| pwd | String | Password |
createToken
Create login token for account
informat.system.createToken(accountId, type);| Parameter | Type | Description |
|---|---|---|
| accountId | String | Account ID |
| type | String | Token typePC index mobilemobile survey surveyweb Exclude system built-in types, also support custom types (e.g.: app, wechat, wemp, etc.) |
Return Value Type: String Returns the authorized TOKEN.
Example
informat.system.createToken("wlt9cgr70o0yi", "index");"581aa91125e74a74a07747ef6862ba41"getAccountByToken
Look up account information by TOKEN
informat.system.getAccountByToken(token);| Parameter | Type | Description |
|---|---|---|
| token | String | TOKEN |
Return Value
Type: Account Returns account information. If the TOKEN does not exist, an empty object is returned.
Example
informat.system.getAccountByToken("581aa91125e74a74a07747ef6862ba41");{
"avatar": "pic16.png",
"companyId": "g09aj7cus3d8s",
"createTime": 1664200514136,
"email": "zhangsan@example.com",
"id": "lwfwqr67xsvup",
"isValid": true,
"mobileNo": "13012345678",
"name": "mr. zhang",
"oid": "zhangsan",
"updateTime": 1683598262000,
"userName": "zhangsan",
"valid": true
}login
Login account
informat.system.login(loginForm);| Parameter | Type | Description |
|---|---|---|
| loginForm | LoginForm | Username or mobile number or email address |
Return Value
Type: LoginResult
| Parameter | Type | Description |
|---|---|---|
| accountId | String | Account ID |
| companyId | String | Company ID |
| errorCode | Integer | Error code |
| token | String | Login token |
Return Value
Type: LoginResult Returns the login result. If the login fails, an error message is returned.
Example
informat.system.login({
userName:'zhangsan',
password:'12345678',
type:'mobile',
ip:'183.46.24.11'
}){
"accountId":"zhangsan",
"companyId":"g09aj7cus3d8s",
"errorCode":0,
"token":"2f7536034b3748c9ba7db15759d01f26"
}validateAccount
Validate username and password
informat.system.validateAccount(user, pwd);| Parameter | Type | Description |
|---|---|---|
| user | String | Username or mobile number |
| pwd | String | Password |
Return Value
If the username and password are valid, it returns true; otherwise, it returns false. The type is Boolean.
informat.system.validateAccount("zhangsan", "12345678"); // falsesetAccountValid
Enable/disable account
informat.system.setAccountValid(accountId, isValid);| Parameter | Type | Description |
|---|---|---|
| accountId | String | Account ID |
| isValid | Boolean | Whether to enable or disable the account |
Example
// Disable the account of mr. zhang
informat.system.setAccountValid("lwfwqr67xsvup", false);
// Enable the account of mr. zhang
informat.system.setAccountValid("lwfwqr67xsvup", true);invokeLibrary
Call a function from an extension library
For more information about libraries, please refer to Libraries
informat.system.invokeLibrary(libraryId, className, method, args);| Parameter | Type | Description |
|---|---|---|
| libraryId | String | Library identifier |
| className | String | Fully qualified class name in the library, e.g. com.mycompany.MyLibaray |
| method | String | Method name to be called, must be static |
| args | Array | Array of arguments to pass to the method, or null if no arguments |
Return Value
Type: Object Returns the return value of the method in the library.
Below is an example
informat.system.invokeLibrary("mylibrary", "com.mycompany.MyLibaray", "add", [1, 2]);If the extension-library function has no parameters
informat.system.invokeLibrary("mylibrary", "com.mycompany.MyLibaray", "test", null);
informat.system.invokeLibrary("mylibrary", "com.mycompany.MyLibaray", "test");For more detailed instructions, please refer to 考Libraries
runProcess
Launch a new process to run the specified command.
informat.system.runProcess(args);| Parameter | Type | Description |
|---|---|---|
| args | ProcessRunArgs | Execution arguments |
ProcessRunArgs Structure
| Attribute | Type | Description |
|---|---|---|
| args | Array<String> | Command arguments |
| timeout | Integer | Timeout in milliseconds, 0 means ignore timeout |
Return Value
Type: ProcessRunResult
| Attribute | Type | Description |
|---|---|---|
| exitValue | Integer | Exit code |
| out | String | Standard output |
| err | String | Error output |
Below is an example
const result = informat.system.runProcess({
cmds: ["java", "-version"],
timeout: 0,
});
console.log(result.out); // java version "11.0.5" 2019-10-15 LTSrunNodeJS
Launch a new process to run Node.js; pass arguments via command-line parameters (cmdline) and standard input (stdin). The Node.js process uses standard output and standard error as return values.
informat.system.runNodeJS(args);| Parameter | Type | Description |
|---|---|---|
| args | RunNodeJSArgs | Execution arguments |
RunNodeJSArgs Structure
| Attribute | Type | Description |
|---|---|---|
| script | String | Script file to execute, e.g. test/helloworld.js |
| cmdline | Array<String> | Command line arguments, subject to operating system length limitations, e.g. 131071 on Linux |
| stdin | String | Standard input |
| env | Object | Environment variables |
Return Value
Type: ProcessRunResult
| Attribute | Type | Description |
|---|---|---|
| exitValue | Integer | Exit code |
| out | String | Standard output |
| err | String | Error output |
Example:
The test script file nodejs/md5test.js is as follows:
/**
*Use the md5 library to compute the MD5 hash of the input string; pass the input parameter via the command line.
*/
var arguments = process.argv;
//Retrieve input parameters
let input = arguments[2];
var md5 = require("md5");
//Pass the result via standard output
console.log(md5(input));Here is the Node.js code to call:
var result = informat.system.runNodeJS({
script: "nodejs/md5test.js",
cmdline: ["123456"],
});
console.log("md5 value:", result.out);queryCompanyList
Query team list
informat.system.queryCompanyList(query);| Parameter | Type | Description |
|---|---|---|
| query | Query | Query filter |
Fields available in the filter
| Field | Type | Description |
|---|---|---|
| id | String | Account ID |
| name | String | Name |
Return Value Return account list, value type is Array Company
Example
informat.system.queryCompanyList({
pageIndex: 1,
pageSize: 10,
filter: {
conditionList: [
{
fieldId: 'name',
opt: 'contains',
value: 'test'
}
]
}
});[
{
"createAccountId":"zhangsan",
"createTime":1665404532125,
"dbIndex":0,
"id":"ukswiyvmqlq5n",
"maxApplicationNum":0,
"maxUserNum":0,
"name":"test team",
"updateTime":1704353335727,
"version":"free"
},
{
"createAccountId":"zhangsan",
"createTime":1669306766288,
"dbIndex":0,
"id":"kkoixbg8ew3ks",
"maxApplicationNum":0,
"maxUserNum":0,
"name":"test team",
"updateTime":1713920870106,
"version":"enterprise"
}
]queryCompanyListCount
Get total count of teams
informat.system.queryCompanyListCount(filter);| Parameter | Type | Description |
|---|---|---|
| filter | Filter | Query filter |
Fields available in the filter
| Field | Type | Description |
|---|---|---|
| id | String | Account ID |
| name | String | Name |
Return Value Type: Integer Return total number of teams
Example
informat.system.queryCompanyListCount({
conditionList: [
{
fieldId: 'name',
opt: 'contains',
value: 'test'
}
]
});2addCompanyMember
Add team member
informat.system.addCompanyMember(companyId, accountId, departmentList, roleList);| Parameter | Type | Description |
|---|---|---|
| companyId | String | Query filter |
| accountId | String | Query filter |
| departmentList | Array(String) | Department list |
| roleList | Array(String) | Role list |
Return Value
Type: Integer
Description: Number of operation records
Example
informat.system.addCompanyMember("g09aj7cus3d8s", "skydu2", ["dev"], ["member"]);queryCompanyDeptList
Query department list in the team
informat.system.queryCompanyDeptList(companyId, query);| Parameter | Type | Description |
|---|---|---|
| companyId | String | Team ID |
| query | Query | Query condition |
List of fields available in the filter
| Parameter | Type | Description |
|---|---|---|
| id | String | Department ID |
| parentId | String | Parent department ID |
| name | String | Department name |
| createTime | Date | Create time |
Return Value Type: Array Dept Return department list
Example 1 Query department list with name containing "dev"
informat.system.queryCompanyDeptList(
'g09aj7cus3d8s',{
pageSize:-1,
filter:{
conditionList:[
{"fieldId":"name","opt":"contains","value":"dev"}
]
}
});[
{
"id": "yanfabu",
"name": "R&D Department",
"parentId": "root",
"remark": "Department responsible for researching and developing new products, technologies, or services",
"rowNumber": 2,
"shortName": "R&D Dept."
}
]getCompanyAllRoles
Query all roles in the team
informat.system.getCompanyAllRoles(companyId);| Parameter | Type | Description |
|---|---|---|
| companyId | String | Team ID |
Return Value
Type: Array CompanyRole Return all roles
Example
informat.system.getCompanyAllRoles('g09aj7cus3d8s')[
{
"admin": true,
"createTime": 1664196760903,
"id": "admin",
"isAdmin": true,
"name": "Administrator",
"permissionIds": [
]
},
{
"admin": false,
"createTime": 1664196760907,
"id": "member",
"isAdmin": false,
"name": "Member",
"permissionIds": [
"InviteMember"
]
}
]addOptLog
Add system log
informat.system.addOptLog(optLog);Parameters
| Parameter | Type | Description |
|---|---|---|
| optLog | OptLog | New operation log |
OptLog structure: ``
| Field | Type | Description |
|---|---|---|
| id | String | Operation record ID |
| type | String | Operation type |
| accountId | String | Operator ID |
| companyId | String | Team ID |
| associatedId | String | Associated ID |
| remark | String | Remarks, appended after operation details |
Optional values for operation type:
| Operation Type | Description |
|---|---|
| CreateAccount | Create Account |
| UpdateAccount | Update Account |
| Register | Register |
| PasswordLogin | Username & Password Login |
| WechatLogin | WeChat QR-Code Login |
| MobileNoLogin | Mobile SMS-Code Login |
| DingTalkLogin | DingTalk Seamless Login |
| WeWorkLogin | WeCom (WeChat Work) Seamless Login |
| ssoLogin | SSO Login |
| Logout | Logout |
| UpdateUserName | Change Login Name |
| UpdateNickName | Change Nickname |
| UpdateMobileNo | Change Mobile Number |
| UpdateEmail | Change Email |
| SwitchCompany | Switch Team |
| InviteMember | Invite Member |
| DeleteMember | Remove Member |
| CreateDepartment | Create Department |
| UpdateDepartment | Edit Department |
| DeleteDepartment | Delete Department |
| CreateRole | Create Role |
| UpdateRole | Edit Role |
| DeleteRole | Delete Role |
| CreateCompany | Create Team |
| CompanySetPro | Set Trial Mode |
| CompanySetModule | Configure Modules |
| CreateApp | Create App |
| UpdateApp | Edit App |
| DeleteApp | Delete App |
| ArchiveApp | Archive App |
| CreateAppMember | Add App Member |
| UpdateAppMember | Edit App Member |
| DeleteAppMember | Remove App Member |
| UpdateAppMemberAccessPassword | Change App-Member Access Password |
| CreateAppModule | Add App Module |
| DeleteAppModule | Remove App Module |
| DeleteRecycleBin | Empty Recycle Bin |
Return Value
Type: Integer
Description: Number of operation records
Example
let optlog = {
accountId: informat.app.userId(),
type: "CreateAccount",
companyId: informat.company.getCompany().id,
remark: "(log)",
};
informat.system.addOptLog(optlog);queryOptLogList
Query operation record list
informat.system.queryOptLogList(query);Parameters
| Parameter | Type | Description |
|---|---|---|
| query | Query | Query conditions |
queryOptLogList Filter Fields
| Field | Type | Description |
|---|---|---|
| type | String | Operation type |
| accountId | String | User who performed the operation |
| remark | String | Remark / Note |
| createTime | String | Creation timestamp |
| updateTime | String | Last update timestamp |
Optional values for operation type:
| Operation Type | Description |
|---|---|
| CreateAccount | Create Account |
| UpdateAccount | Update Account |
| Register | Register |
| PasswordLogin | Username & Password Login |
| WechatLogin | WeChat QR-Code Login |
| MobileNoLogin | Mobile SMS-Code Login |
| DingTalkLogin | DingTalk Seamless Login |
| WeWorkLogin | WeCom (WeChat Work) Seamless Login |
| ssoLogin | SSO Login |
| Logout | Logout |
| UpdateUserName | Change Login Name |
| UpdateNickName | Change Nickname |
| UpdateMobileNo | Change Mobile Number |
| UpdateEmail | Change Email |
| SwitchCompany | Switch Team |
| InviteMember | Invite Member |
| DeleteMember | Remove Member |
| CreateDepartment | Create Department |
| UpdateDepartment | Edit Department |
| DeleteDepartment | Delete Department |
| CreateRole | Create Role |
| UpdateRole | Edit Role |
| DeleteRole | Delete Role |
| CreateCompany | Create Team |
| CompanySetPro | Set Trial Mode |
| CompanySetModule | Configure Modules |
| CreateApp | Create App |
| UpdateApp | Edit App |
| DeleteApp | Delete App |
| ArchiveApp | Archive App |
| CreateAppMember | Add App Member |
| UpdateAppMember | Edit App Member |
| DeleteAppMember | Remove App Member |
| UpdateAppMemberAccessPassword | Change App-Member Access Password |
| CreateAppModule | Add App Module |
| DeleteAppModule | Remove App Module |
| DeleteRecycleBin | Empty Recycle Bin |
queryOptLogList Return Value
Type: Array OptLog, operation record list
queryOptLogList Example
let query = {
pageSize:-1,
filter: {
conditionList:[
{fieldId:'type', opt: 'eq', value: 'CreateAccount'}
]
}
}
informat.system.queryOptLogList(query)[
{
"accountAvatar": "2e6e1b0512aa4d4c8c36221cde76027b.jpg",
"accountId": "lisi",
"accountName": "mr.li",
"associatedId": "zhangsan",
"companyId": "g09asd3qs3d8s",
"companyName": "Test Team",
"createTime": 1709863371382,
"id": "cv7q7u8rnuksb",
"remark": "Create account: zhangsan",
"type": "CreateAccount",
"updateTime": 1709863371382
}
]queryOptLogListCount
Query operation record count
informat.system.queryOptLogListCount(filter);Parameters
| Parameter | Type | Description |
|---|---|---|
| filter | Filter | Filter condition |
List of fields available in the filter
| Field | Type | Description |
|---|---|---|
| type | String | Operation type |
| accountId | String | User who performed the operation |
| remark | String | Remark / Note |
Operation type optional values:
| Operation Type | Description |
|---|---|
| CreateAccount | Create Account |
| UpdateAccount | Update Account |
| Register | Register |
| PasswordLogin | Username & Password Login |
| WechatLogin | WeChat QR-Code Login |
| MobileNoLogin | Mobile SMS-Code Login |
| DingTalkLogin | DingTalk Seamless Login |
| WeWorkLogin | WeCom (WeChat Work) Seamless Login |
| ssoLogin | SSO Login |
| Logout | Logout |
| UpdateUserName | Change Login Name |
| UpdateNickName | Change Nickname |
| UpdateMobileNo | Change Mobile Number |
| UpdateEmail | Change Email |
| SwitchCompany | Switch Team |
| InviteMember | Invite Member |
| DeleteMember | Remove Member |
| CreateDepartment | Create Department |
| UpdateDepartment | Edit Department |
| DeleteDepartment | Delete Department |
| CreateRole | Create Role |
| UpdateRole | Edit Role |
| DeleteRole | Delete Role |
| CreateCompany | Create Team |
| CompanySetPro | Set Trial Mode |
| CompanySetModule | Configure Modules |
| CreateApp | Create App |
| UpdateApp | Edit App |
| DeleteApp | Delete App |
| ArchiveApp | Archive App |
| CreateAppMember | Add App Member |
| UpdateAppMember | Edit App Member |
| DeleteAppMember | Remove App Member |
| UpdateAppMemberAccessPassword | Change App-Member Access Password |
| CreateAppModule | Add App Module |
| DeleteAppModule | Remove App Module |
| DeleteRecycleBin | Empty Recycle Bin |
Return Value
Type: Integer
Description: Number of operation records
Example
let filter = {
conditionList: [{ fieldId: "type", opt: "eq", value: "CreateAccount" }],
};
informat.system.queryOptLogListCount(filter);6deleteOptLogList
Batch delete system logs
informat.system.deleteOptLogList(filter);Parameters
| Parameter | Type | Description |
|---|---|---|
| filter | Filter | Filter conditions |
List of fields available in the filter
| Field | Type | Description |
|---|---|---|
| type | String | Operation type |
| accountId | String | User who performed the operation |
| remark | String | Remark / Note |
| createTime | String | Creation timestamp |
| updateTime | String | Last update timestamp |
Return Value
Type: Integer
Description: Number of operation records deleted
Example
let filter = {
conditionList:[
{fieldId:'type', opt: 'eq', value: 'CreateAccount'}
]
}
informat.system.deleteOptLogList(filter)6runWithContext
Cross-team and cross-app execution of script functions
informat.system.runWithContext(context, func);Parameters
| Parameter | Type | Description |
|---|---|---|
| context | RunWithContext | Context configuration |
| func | Function | Function to execute |
RunWithContext structure:
| Parameter | Type | Description |
|---|---|---|
| companyId | String | Team ID, default is current team |
| appDefineId | String | Application identifier, default is current app |
Return Value
Type: Depends on the function executed
Description: Return value of the executed function
Example
const addMember = () => {
informat.user.addUser(informat.app.userId(), ['admin'])
return true
}
let context = {
companyId: 'xxxxxxxxxx',
appDefineId: 'com.myApp'
}
informat.system.runWithContext(context, addMember)trueuploadFile
Upload local files to shared storage. Note: If a file with the same name exists in the local directory, it will be overwritten
informat.system.uploadFile(localPath, remotePath);Parameters
| Parameter | Type | Description |
|---|---|---|
| localPath | String | Local file path |
| remotePath | String | Shared storage path |
Return Value
None
Example
// Upload the avatar file; it must be placed in the public directory.
const localPath = "local.png";
const remotePath = "public/newAvatar.png";
informat.system.uploadFile(localPath, remotePath);
// Update the user avatar to the new avatar file.
informat.system.updateAccount({
id: "ap1cew2up9ehq",
avatar: "newAvatar.png",
});setPasswordRule
Set password rules
informat.system.setPasswordRule(reg);Parameters
| Parameter | Type | Description |
|---|---|---|
| reg | String | Password rule (regular expression) |
Return Value
None
Example
// Set the password rule to 7-20 characters, including numbers, letters, and special characters.
informat.system.setPasswordRule("^w{7,20}$");executeAsync
Execute tasks asynchronously (in a new thread)
informat.system.executeAsync(func, arg);Parameters
| Parameter | Type | Description |
|---|---|---|
| func | Function | Lambda function, cannot be empty |
| arg | Object | Input parameter for the function |
| successCallback | Function | Success callback function, can be empty |
| failedCallback | Function | Failed callback function, can be empty |
Return Value
None
Example
function asyncTask(input) {
console.log("asyncTask start: " + input);
return informat.table.insert("dataModelBasics", {
singleText: input,
});
}
function successCallback(result) {
console.log("asyncTask result: " + result);
return informat.table.insert("dataModelBasics", {
singleText: "success",
});
}
function failedCallback(exception) {
console.log("asyncTask exception: " + exception);
return informat.table.insert("dataModelBasics", {
singleText: "failed",
});
}
informat.system.executeAsync(asyncTask, "123", successCallback, failedCallback);getTokenByAccount
Query login credentials by account ID and type
informat.system.getTokenByAccount(accountId, type);Parameters
| Parameter | Type | Description |
|---|---|---|
| accountId | String | Account ID |
| type | String | Type, optional values: index, mobile |
Return Value AccountToken
Example
let token = informat.system.getTokenByAccount('zhangsan', 'index');
console.log(token){
"accountId": "zhangsan",
"companyId": "g09aj7cus3d8s",
"createTime": 1744809507322,
"dbIndex": 0,
"expireTime": 1744827749095,
"token": "b4b5013a483844c7b290808194f58418",
"type": "index"
}updateTokenExpireTime
Update login token expiration time
informat.system.updateTokenExpireTime(token, expireTime);Parameters
| Parameter | Type | Description |
|---|---|---|
| token | String | Login token |
| expireTime | Date | Expiration time |
Return Value None

