Expression-related
Overview
Informat provides the ability to invoke expression-based methods within scripts. The supported expressions are:
| Category | Description | Details |
|---|---|---|
| Array | Collection | Functions related to arrays/collections |
| Date | Date & Time | Functions for date/time calculations |
| Encode | Character Encoding | Functions for string encoding/decoding |
| Math | Number | Mathematical operations |
| Misc | Miscellaneous | Other utility functions |
| String | String | Functions related to string manipulation |
| User | User | Functions for operating on users in the current system |
| Context | Context | Functions that access runtime context (environment parameters) |
| Record | Data Table Record | Functions related to data-table records |
| T | Internationalization | Functions for internationalization (i18n) |
Array
Array collection-related functions, called as informat.Array.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| of | ...item: Object | Array<Object> | Creates an array from the given elements. | informat.Array.of('x', 2, 3) // ["x", 2, 3] |
| toList | item: Object | Array<Object> | Converts the element to an array; clones it if already an array. | informat.Array.toList('x') // ["x"] |
| join | array: Array, separator: String | String | Joins array elements with the specified separator. | informat.Array.join([1, 2, 3], '-') // "1-2-3" |
| length | list: Array | Integer | Returns the length of the array; returns 0 for null. | informat.Array.length([1, 2, 3]) // 3 |
| get | list: Array|Map, key: Integer|String | Object | Retrieves the element at the specified index/key. | informat.Array.get([{name: '张三'}], 0) // {name: '张三'} |
| set | list: Array|Map, key: String|Integer, value: Object | Array|Map | Sets the value of the element at the specified index/key. | informat.Array.set({name: '张三'}, 'name', '李四') |
| add | list: Array, item: Object | Array | Appends the element to the end of the array. | informat.Array.add([1, 2], 3) // [1, 2, 3] |
| remove | list: Array|Map, item: Object|String | Array|Map | Removes the first matching element. | informat.Array.remove([1, 2, 3], 2) // [1, 3] |
| removeAll | list: Array|Map, item: Object|String|Array | Array|Map | Removes all matching elements. | informat.Array.removeAll([1, 2, 2, 3], 2) // [1, 3] |
| isEmpty | list: Array|Map | Boolean | Returns true if the collection is empty. | informat.Array.isEmpty([]) // true |
| isNotEmpty | list: Array|Map | Boolean | Returns true if the collection is not empty. | informat.Array.isNotEmpty([1]) // true |
| contains | list: Array|Map, item: Object | Boolean | Returns true if the collection contains the specified element. | informat.Array.contains([1, 2, 3], 2) // true |
| containsAny | list1: Array, list2: Array | Boolean | Returns true if list1 contains any element of list2. | informat.Array.containsAny([1, 2], [2, 3]) // true |
| containsAll | list1: Array, list2: Array | Boolean | Returns true if list1 contains all elements of list2. | informat.Array.containsAll([1, 2, 3], [1, 2]) // true |
| map | list: Array, key: String | Array | Returns an array of the specified property from each element. | informat.Array.map([{name: '张三'}], 'name') // ["张三"] |
| props | list: Array, props: Array<String> | Array | Returns a new array of objects with only the specified properties. | informat.Array.props([{name: '张三'}], ['name']) // [{name: '张三'}] |
| transform | list: Array, mapping: Map<String,String> | Array | Transforms object properties according to the mapping. | informat.Array.transform([{name: '张三'}], {name: 'userName'}) |
| concat | list1: Array, list2: Array | Array | Concatenates two arrays. | informat.Array.concat([1, 2], [3, 4]) // [1, 2, 3, 4] |
| sort | list: Array, key: String | Array | Sorts the array by the specified property. | informat.Array.sort([{age: 20}, {age: 18}], 'age') |
| distinct | list: Array | Array | Returns a new array with duplicate elements removed. | informat.Array.distinct([1, 2, 2, 3]) // [1, 2, 3] |
| reverse | list: Array | Array | Reverses the order of the array. | informat.Array.reverse([1, 2, 3]) // [3, 2, 1] |
| repeat | count: Integer, element: Object | Array | Creates an array by repeating the element. | informat.Array.repeat(3, 'a') // ["a", "a", "a"] |
| sublist | list: Array, fromIndex: Integer, toIndex: Integer | Array | Returns a sublist from the specified range. | informat.Array.sublist([1, 2, 3, 4], 1, 2) // [2, 3] |
| filter | list: Array, key: String, value: Object | Array | Filters elements by the specified property value. | informat.Array.filter([{a: 1}, {a: 2}], "a", 2) // [{a: 2}] |
| shift | list: Array | Object | Removes and returns the first element. | informat.Array.shift([1, 2, 3]) // 1 |
| pop | list: Array | Object | Removes and returns the last element. | informat.Array.pop([1, 2, 3]) // 3 |
| sum | list: Array | Double | Returns the sum of numeric elements. | informat.Array.sum([1, 2, 3]) // 6.0 |
| avg | list: Array | Double | Returns the average of numeric elements. | informat.Array.avg([1, 2, 3]) // 2.0 |
| max | list: Array | Double | Returns the maximum numeric value. | informat.Array.max([1, 2, 3]) // 3.0 |
| min | list: Array | Double | Returns the minimum numeric value. | informat.Array.min([1, 2, 3]) // 1.0 |
| first | list: Array | Object | Returns the first element. | informat.Array.first([1, 2, 3]) // 1 |
| last | list: Array | Object | Returns the last element. | informat.Array.last([1, 2, 3]) // 3 |
Date
Date-calculation functions; invoked as informat.Date.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| sysdate | none | Date | Returns the current date and time. | informat.Date.sysdate() // Date object |
| now | none | Long | Returns the current UNIX timestamp in milliseconds. | informat.Date.now() // 1668483800328 |
| newDate | year, month, day, hour, minute, second, millisecond (all Integer, optional) | Date | Creates a date from the given values; all parameters are optional. | informat.Date.newDate(2025, 0, 3) // 2025-01-03 00:00:00.000 |
| dateSet | d: Date or Long, type: String, value: Integer | Date | Sets the specified field of the date to the given value. | informat.Date.dateSet(date, 'year', 2024) // sets year to 2024 |
| dateAdd | d: Date or Long, type: String, diff: Integer | Date | Adds the given amount to the specified field of the date. | informat.Date.dateAdd(date, 'year', 1) // adds 1 year |
| datePart | d: Date or Long, type: String | Integer | Extracts the value of the specified field from the date. | informat.Date.datePart(date, 'year') // returns the year |
| dateBefore | d1: Date or Long, d2: Date or Long | Boolean | Returns true if d1 is before d2. | informat.Date.dateBefore(date1, date2) // true/false |
| dateAfter | d1: Date or Long, d2: Date or Long | Boolean | Returns true if d1 is after d2. | informat.Date.dateAfter(date1, date2) // true/false |
| dateDiff | d1: Date or Long, d2: Date or Long | Integer | Calculates the difference in days between two dates. | informat.Date.dateDiff(date1, date2) // day difference |
| monthDiff | d1: Date or Long, d2: Date or Long | Integer | Calculates the difference in months between two dates. | informat.Date.monthDiff(date1, date2) // month difference |
| weekDiff | d1: Date or Long, d2: Date or Long | Integer | Calculates the difference in weeks between two dates. | informat.Date.weekDiff(date1, date2) // week difference |
| quarterDiff | d1: Date or Long, d2: Date or Long | Integer | Calculates the difference in quarters between two dates. | informat.Date.quarterDiff(date1, date2) // quarter difference |
Special Notes
month Value range
| Month | Value |
|---|---|
| 1 | 0 |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| 6 | 5 |
| 7 | 6 |
| 8 | 7 |
| 9 | 8 |
| 10 | 9 |
| 11 | 10 |
| 12 | 11 |
day_of_week Value range
| Day | Value |
|---|---|
| Sunday | 0 |
| Monday | 1 |
| Tuesday | 2 |
| Wednesday | 3 |
| Thursday | 4 |
| Friday | 5 |
| Saturday | 6 |
Encode
String encoding and decoding functions; invoked as informat.Encode.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| md5 | s: String | String | Returns the MD5 hash value of the string. | informat.Encode.md5('123456') // e10adc3949ba59abbe56e057f20f883e |
| urlEncode | str: String | String | Encodes the string for use in a URL. | informat.Encode.urlEncode('https://next.informat.cn') // https%3A%2F%2Fnext.informat.cn |
| urlDecode | str: String | String | Decodes the string from a URL. | informat.Encode.urlDecode('https%3A%2F%2Fnext.informat.cn') // https://next.informat.cn |
Math
Mathematical functions; invoked as informat.Math.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| abs | x: Integer或Double | Integer或Double | Returns the absolute value of the number. | informat.Math.abs(-100.3) // 100.3 |
| pow | d1: Integer或Double, d2: Integer或Double | Double | Returns d1 raised to the power of d2. | informat.Math.pow(2, 3) // 8.0 |
| ceil | x: Double | Double | Returns the smallest integer greater than or equal to x. | informat.Math.ceil(2.2) // 3.0 |
| floor | x: Double | Double | Returns the largest integer less than or equal to x. | informat.Math.floor(2.2) // 2.0 |
| random | None | Double | Returns a random number between 0 and 1. | informat.Math.random() // 0.6260832016946124 |
| sqrt | x: Double | Double | Returns the square root of x. | informat.Math.sqrt(4) // 2.0 |
| round | n: Double, digits: Integer | Double | Rounds the number to the specified number of decimal places. | informat.Math.round(3.1415926, 2) // 3.14 |
Misc
Utility functions; invoked as informat.Misc.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| jsonStringify | obj: Object | String | Converts an object to a JSON string. | informat.Misc.jsonStringify({a:1}) // "{\"a\":1}" |
| jsonParse | str: String | Object | Converts a JSON string to an object. | informat.Misc.jsonParse('{"a":1}') // {a:1} |
| parseFloat | str: String | Double | Converts a string to a floating-point number. | informat.Misc.parseFloat("3.14") // 3.14 |
| parseInt | str: String | Integer | Converts a string to an integer. | informat.Misc.parseInt("3.14") // 3 |
| timestampToDate | timestamp: Integer | Date | Converts a UNIX timestamp to a date. | informat.Misc.timestampToDate(1667232000000) |
| dateToTimestamp | date: Date | Integer | Converts a date to a UNIX timestamp. | informat.Misc.dateToTimestamp(new Date()) |
| formatDate | date: Date, fmt: String | String | Formats the date according to the specified format. | informat.Misc.formatDate(date, 'yyyy-MM-dd') |
| parseDate | str: String, fmt: String | Date | Parses a date string according to the specified format. | informat.Misc.parseDate('2022-11-01', 'yyyy-MM-dd') |
| host | None | String | Returns the system home page address. | informat.Misc.host() // https://next.informat.cn/ |
| pinyin | str: String | String | Returns the pinyin of the string. | informat.Misc.pinyin('你好') // "ni hao" |
| shortPinyin | str: String | String | Returns the first letter of the pinyin. | informat.Misc.shortPinyin('你好') // "nh" |
| expectNotNull | obj: Object, message: String | Object | Checks if the object is not null; throws an exception if it is null. | informat.Misc.expectNotNull(obj, '不能为空') |
| expectFirst | array: Array, message: String | Object | Returns the first element of the array. | informat.Misc.expectFirst([1,2], '空数组') // 1 |
| expectLast | array: Array, message: String | Object | Returns the last element of the array. | informat.Misc.expectLast([1,2], '空数组') // 2 |
| invokeScript | script: String, func: String, ...args: Object | Object | Invokes a function in the specified script. | informat.Misc.invokeScript('test.js', 'add', 1, 2) |
| invokeAutomatic | automaticId: String, ...args: Object | Object | Invokes an automatic program. | informat.Misc.invokeAutomatic('test', 1, 2) |
| httpGet | url: String | String | Accesses the URL using the GET method. | informat.Misc.httpGet('https://example.com') |
| prop | object: Object, key: String | Object | Returns the value of the specified property. | informat.Misc.prop({a:1}, 'a') // 1 |
| props | object: Object, props: Array<String> | Object | Returns a new object with the specified properties. | informat.Misc.props({a:1,b:2}, ['a']) |
| transform | object: Object, mapping: Map<String,String> | Object | Transforms the object properties according to the mapping relationship. | informat.Misc.transform({name:'张三'}, {name:'userName'}) |
| appId | None | String | Returns the ID of the current application. | informat.Misc.appId() |
| getAppIdByKey | key: String | String | Returns the application ID by the application key. | informat.Misc.getAppIdByKey('appKey') |
| attachmentURL | tableKey: String, fieldKey: String, value: String | String | Returns the attachment access link. | informat.Misc.attachmentURL('staff','photo','1.png') |
| appResURL | appResId: String | String | Returns the application resource library resource address. | informat.Misc.appResURL('image.jpg') |
| websiteResURL | moduleKey: String, filePath: String | String | Returns the website module resource address. | informat.Misc.websiteResURL('module','logo.png') |
| barcodeURL | value: String, format: String | String | Returns the barcode image BASE64 value. | informat.Misc.barcodeURL('12345','CODE128') |
| qrcodeURL | value: String, width: Integer | String | Returns the QR code image BASE64 value. | informat.Misc.qrcodeURL('text', 300) |
| eval | str: String, context: Object | Object | Evaluates the expression engine template. | informat.Misc.eval('${name}', {name:'test'}) |
| safesql | sql: String, params: Array<Object> | String | Generates a safe SQL statement with parameter placeholders. | informat.Misc.safesql('select ?', ['test']) |
| uuid16 | None | String | Generates a 16-character UUID string. | informat.Misc.uuid16() // "lqjfw3xaglp38tru" |
| uuid32 | None | String | Generates a 32-character UUID string. | informat.Misc.uuid32() // "rigzv6usysisu2gmkash6hdg526y10b5" |
| newObject | None | Object | Builds an empty object. | informat.Misc.newObject() // {} |
| recordSql | sql: String, parameters: Array<Object> | Array<Object> | Executes a SQL query to retrieve table records. | informat.Misc.recordSql('select * from table', []) |
String
String-related functions; invoked as informat.String.method.
| Method | Parameters | Return Type | Description | Example | | upper | s: String | String | Convert all letters in the string to uppercase. | informat.String.upper('abc') // "ABC" | | lower | s: String | String | Convert all letters in the string to lowercase. | informat.String.lower('ABC') // "abc" | | concat | s1: String, s2: String | String | Concatenate two strings. | informat.String.concat('a','b') // "ab" | | lpad | s1: String, len: Integer, s2: String | String | Pad the string with characters at the beginning. | informat.String.lpad('ABC',6,'0') // "000ABC" | | rpad | s1: String, len: Integer, s2: String | String | Pad the string with characters at the end. | informat.String.rpad('ABC',6,'0') // "ABC000" | | trim | s: String | String | Remove leading and trailing whitespace characters from the string. | informat.String.trim(' abc ') // "abc" | | replace | s: String, s1: String, s2: String | String | Replace the first occurrence of a substring with another substring. | informat.String.replace('abca','a','_') // "_bca" | | replaceAll | s: String, s1: String, s2: String | String | Replace all occurrences of a substring with another substring. | informat.String.replaceAll('abca','a','_') // "_bc_" | | substr | s: String, start: Integer, len: Integer | String | Get a substring from the specified position with the specified length. | informat.String.substr('abcd',1,2) // "bc" | | substring | s: String, start: Integer, end: Integer | String | Get a substring from the specified start position to the specified end position. | informat.String.substring('abcd',0,2) // "ab" | | indexOf | s: String, s2: String | Integer | Get the index of the first occurrence of a substring. | informat.String.indexOf('abcd','a') // 0 | | lastIndexOf | s: String, s2: String | Integer | Get the index of the last occurrence of a substring. | informat.String.lastIndexOf('abcad','a') // 3 | | contains | s: String, s2: String | Boolean | Check if the string contains the specified substring. | informat.String.contains('abcd','a') // true | | length | s: String | Integer | Get the length of the string. | informat.String.length('abcd') // 4 | | startsWith | s: String, s2: String | Boolean | Check if the string starts with the specified substring. | informat.String.startsWith('abcd','a') // true | | endsWith | s: String, s2: String | Boolean | Check if the string ends with the specified substring. | informat.String.endsWith('abcd','d') // true | | match | regex: String, input: String | Boolean | Validate the string using the regular expression. | informat.String.match('^[a-z]+','abcd') // true | | isEmpty | s: String | Boolean | Check if the string is empty (trimmed). | informat.String.isEmpty(' ') // true | | isNotEmpty | s: String | Boolean | Check if the string is not empty (trimmed). | informat.String.isNotEmpty('a') // true | | html2text | s: String | String | Convert HTML content to text (XSS filtering). | informat.String.html2text('<div>test</div>') // "test" |
User
User-related functions; invoked as informat.User.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| usersWithRole | roleIdList: Array<String> | Array<String> | Returns a list of users who have any of the specified roles. | informat.User.usersWithRole(['admin']) // [user1, user2, user3] |
| usersWithDepartment | departmentIdList: Array<String> | Array<String> | Returns a list of users who belong to any of the specified departments. | informat.User.usersWithDepartment(['yanfabu']) |
| superiorUsers | userId: String | Array<String> | Returns a list of direct superior users of the specified user. | informat.User.superiorUsers('user1') // [user2, user3] |
| superiorUsersWithLevel | userId: String, level: Integer | Array<String> | Returns a list of direct superior users of the specified user up to the specified level. | informat.User.superiorUsersWithLevel(Context.userId(), 1) |
| subordinateUsers | userId: String | Array<String> | Returns a list of direct subordinate users of the specified user. | informat.User.subordinateUsers('user1') // [user2, user3] |
| subordinateUsersWithLevel | userId: String, level: Integer | Array<String> | Returns a list of direct subordinate users of the specified user up to the specified level. | informat.User.subordinateUsersWithLevel('user1', 2) // [user2, user3] |
| leaderOfDept | departmentId: String | Array<String> | Returns a list of direct department leader users for the specified department. | informat.User.leaderOfDept('dept1') // [user2, user3] |
| leaderOfDeptWithLevel | departmentId: String, level: Integer | Array<String> | Returns a list of direct department leader users for the specified department up to the specified level. | informat.User.leaderOfDeptWithLevel('yanfabu', 1) |
| leaderOfDeptList | departmentIdList: Array<String> | Array<String> | Returns a list of direct department leader users for the specified departments. | informat.User.leaderOfDeptList(['dept1', 'dept2']) // [user2, user3, user4] |
| parentOfDept | departmentId: String | String | Returns the direct parent department ID of the specified department. | informat.User.parentOfDept('dept1') // dept2 |
| parentOfDeptList | departmentId: String | Array<String> | Returns a list of all parent department IDs for the specified department. | informat.User.parentOfDeptList('dept1') // ['dept2', 'dept3'] |
| childrenOfDept | departmentId: String | Array<String> | Returns a list of all child department IDs for the specified department (recursively). | informat.User.childrenOfDept('dept1') // [dept2, dept3] |
| childrenOfDeptList | departmentList: Array<String> | Array<String> | Returns a list of all child department IDs for the specified departments (recursively). | informat.User.childrenOfDeptList(['dept1', 'dept2']) // [dept2, dept3] |
| directChildrenOfDept | departmentId: String | Array<String> | Returns a list of all direct child department IDs for the specified department. | informat.User.directChildrenOfDept('dept1') // [dept2] |
| user | userId: String | User | Returns a user information object. | informat.User.user(Context.userId()) |
| userInfo | userId: String | UserInfo | Returns a user detailed information object. | informat.User.userInfo(Context.userId()) |
| deptList | departmentIdList: Array<String> | Array<Dept> | Returns a list of department information objects. | informat.User.deptList(['dept1', 'dept2']) |
| dept | deptId: String | Dept | Returns a department information object. | informat.User.dept('dept1') |
Context
Context-related functions; invoked as informat.Context.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| userId | No Parameters | String | Returns the ID of the current operating user. | informat.Context.userId() // "ek5veueb6c9zg" |
| appId | No Parameters | String | Returns the ID of the current application. | informat.Context.appId() |
| appEnvProp | propKey: String | String | Returns the value of the specified application environment property. | informat.Context.appEnvProp('payURL') // "http://dev-demo.com/pay" |
| httpHeaders | No Parameters | Object | Returns the HTTP request header information. | informat.Context.httpHeaders() // {headers: {...}} |
| clipboardType | No Parameters | String | Returns the type of data stored in the application clipboard. | informat.Context.clipboardType() // "test" |
| clipboardData | No Parameters | Object | Returns the data stored in the application clipboard. | informat.Context.clipboardData() |
| weworkAccessToken | No Parameters | String | Returns the enterprise WeWork AccessToken. | informat.Context.weworkAccessToken() |
| dingtalkAccessToken | No Parameters | String | Returns the DingTalk AccessToken. | informat.Context.dingtalkAccessToken() |
| feishuAccessToken | No Parameters | String | Returns the Feishu application AccessToken. | informat.Context.feishuAccessToken() |
| feishuTenantAccessToken | No Parameters | String | Returns the Feishu tenant AccessToken. | informat.Context.feishuTenantAccessToken() |
| requestIp | No Parameters | String | Returns the IP address of the current request. | informat.Context.requestIp() // "192.168.1.1" |
| hasAppPerm | permKey: String | Boolean | Returns whether the current user has the specified application permission. | informat.Context.hasAppPerm('admin') // true |
| hasModulePerm | moduleKey: String, permKey: String | Boolean | Returns whether the current user has the specified module permission. | informat.Context.hasModulePerm('crm', 'read') // true |
Record
Record-related functions; invoked as informat.Record.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| getById | tableId: String, recordId: String | Object | Retrieves a single record by ID. | informat.Record.getById('order', 'z2koxrkxtp854') // {amount:11, name:'Test PO', id:'z2koxrkxtp854'} |
| getFieldValue | tableId: String, recordId: String, fieldId: String | Object | Returns the value of the specified field in the record. | informat.Record.getFieldValue('order','z2koxrkxtp854','amount') // 11 |
| getByField | tableId: String, fieldId: String, opt: String, value: Object | Array<Record> | Filters records by a single field condition. | informat.Record.getByField('order', 'amount', 'eq', 11) // [{amount:11, name:'Test PO', id:'z2koxrkxtp854'}] |
| getByFields | tableId: String, conditions: Array | Array<Record> | Filters records by multiple field conditions. | informat.Record.getByFields('tab', [{fieldId:'text', opt:'eq', value:'13'}]) // [{amount:11, text:'13', id:'z2koxrkxtp854'}] |
| getRecordOptionName | tableId: String, fieldId: String, value: String | String | Returns the display name of a single option value. | informat.Record.getRecordOptionName('order', 'type', 'a') // "Option 1" |
| getRecordOptionNames | tableId: String, fieldId: String, valueList: Array<String>, join: String | String | Returns the display names of multiple option values, joined by the separator. | informat.Record.getRecordOptionNames('order', 'type', ['a','b'], ',') // "Option 1, Option 2" |
| getRecordOptions | tableId: String, fieldId: String | Array<Option> | Returns the list of available options for the field. | informat.Record.getRecordOptions('order', 'type') // [{id:'a', name:'Option 1'}, {id:'b', name:'Option 2'}] |
| getRelationList | tableId: String, fieldId: String, recordId: String | Array<Record> | Returns the records linked via a relation-list field. | informat.Record.getRelationList('order','orderDetail','z2koxrkxtp854') |
T
Internationalization-related functions; invoked as informat.T.method.
| Method | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
| locale | No Parameters | String | Returns the current language used for translation. | informat.T.locale() // "zh-CN" |
| t | key: String, args: Object/Array | String | Translates the specified key using the current language and arguments. | informat.T.t('welcome.message') // "欢迎" |
| tWithLocale | locale: String, key: String, args: Object/Array | String | Translates the specified key using the specified language and arguments. | informat.T.tWithLocale('en-US', 'welcome.message') // "Welcome" |

