Skip to content

Expression-related

Overview

Informat provides the ability to invoke expression-based methods within scripts. The supported expressions are:

CategoryDescriptionDetails
ArrayCollectionFunctions related to arrays/collections
DateDate & TimeFunctions for date/time calculations
EncodeCharacter EncodingFunctions for string encoding/decoding
MathNumberMathematical operations
MiscMiscellaneousOther utility functions
StringStringFunctions related to string manipulation
UserUserFunctions for operating on users in the current system
ContextContextFunctions that access runtime context (environment parameters)
RecordData Table RecordFunctions related to data-table records
TInternationalizationFunctions for internationalization (i18n)

Array

Array collection-related functions, called as informat.Array.method.

MethodParametersReturn TypeDescriptionExample
of...item: ObjectArray<Object>Creates an array from the given elements.informat.Array.of('x', 2, 3) // ["x", 2, 3]
toListitem: ObjectArray<Object>Converts the element to an array; clones it if already an array.informat.Array.toList('x') // ["x"]
joinarray: Array, separator: StringStringJoins array elements with the specified separator.informat.Array.join([1, 2, 3], '-') // "1-2-3"
lengthlist: ArrayIntegerReturns the length of the array; returns 0 for null.informat.Array.length([1, 2, 3]) // 3
getlist: Array|Map, key: Integer|StringObjectRetrieves the element at the specified index/key.informat.Array.get([{name: '张三'}], 0) // {name: '张三'}
setlist: Array|Map, key: String|Integer, value: ObjectArray|MapSets the value of the element at the specified index/key.informat.Array.set({name: '张三'}, 'name', '李四')
addlist: Array, item: ObjectArrayAppends the element to the end of the array.informat.Array.add([1, 2], 3) // [1, 2, 3]
removelist: Array|Map, item: Object|StringArray|MapRemoves the first matching element.informat.Array.remove([1, 2, 3], 2) // [1, 3]
removeAlllist: Array|Map, item: Object|String|ArrayArray|MapRemoves all matching elements.informat.Array.removeAll([1, 2, 2, 3], 2) // [1, 3]
isEmptylist: Array|MapBooleanReturns true if the collection is empty.informat.Array.isEmpty([]) // true
isNotEmptylist: Array|MapBooleanReturns true if the collection is not empty.informat.Array.isNotEmpty([1]) // true
containslist: Array|Map, item: ObjectBooleanReturns true if the collection contains the specified element.informat.Array.contains([1, 2, 3], 2) // true
containsAnylist1: Array, list2: ArrayBooleanReturns true if list1 contains any element of list2.informat.Array.containsAny([1, 2], [2, 3]) // true
containsAlllist1: Array, list2: ArrayBooleanReturns true if list1 contains all elements of list2.informat.Array.containsAll([1, 2, 3], [1, 2]) // true
maplist: Array, key: StringArrayReturns an array of the specified property from each element.informat.Array.map([{name: '张三'}], 'name') // ["张三"]
propslist: Array, props: Array<String>ArrayReturns a new array of objects with only the specified properties.informat.Array.props([{name: '张三'}], ['name']) // [{name: '张三'}]
transformlist: Array, mapping: Map<String,String>ArrayTransforms object properties according to the mapping.informat.Array.transform([{name: '张三'}], {name: 'userName'})
concatlist1: Array, list2: ArrayArrayConcatenates two arrays.informat.Array.concat([1, 2], [3, 4]) // [1, 2, 3, 4]
sortlist: Array, key: StringArraySorts the array by the specified property.informat.Array.sort([{age: 20}, {age: 18}], 'age')
distinctlist: ArrayArrayReturns a new array with duplicate elements removed.informat.Array.distinct([1, 2, 2, 3]) // [1, 2, 3]
reverselist: ArrayArrayReverses the order of the array.informat.Array.reverse([1, 2, 3]) // [3, 2, 1]
repeatcount: Integer, element: ObjectArrayCreates an array by repeating the element.informat.Array.repeat(3, 'a') // ["a", "a", "a"]
sublistlist: Array, fromIndex: Integer, toIndex: IntegerArrayReturns a sublist from the specified range.informat.Array.sublist([1, 2, 3, 4], 1, 2) // [2, 3]
filterlist: Array, key: String, value: ObjectArrayFilters elements by the specified property value.informat.Array.filter([{a: 1}, {a: 2}], "a", 2) // [{a: 2}]
shiftlist: ArrayObjectRemoves and returns the first element.informat.Array.shift([1, 2, 3]) // 1
poplist: ArrayObjectRemoves and returns the last element.informat.Array.pop([1, 2, 3]) // 3
sumlist: ArrayDoubleReturns the sum of numeric elements.informat.Array.sum([1, 2, 3]) // 6.0
avglist: ArrayDoubleReturns the average of numeric elements.informat.Array.avg([1, 2, 3]) // 2.0
maxlist: ArrayDoubleReturns the maximum numeric value.informat.Array.max([1, 2, 3]) // 3.0
minlist: ArrayDoubleReturns the minimum numeric value.informat.Array.min([1, 2, 3]) // 1.0
firstlist: ArrayObjectReturns the first element.informat.Array.first([1, 2, 3]) // 1
lastlist: ArrayObjectReturns the last element.informat.Array.last([1, 2, 3]) // 3

Date

Date-calculation functions; invoked as informat.Date.method.

MethodParametersReturn TypeDescriptionExample
sysdatenoneDateReturns the current date and time.informat.Date.sysdate() // Date object
nownoneLongReturns the current UNIX timestamp in milliseconds.informat.Date.now() // 1668483800328
newDateyear, month, day, hour, minute, second, millisecond (all Integer, optional)DateCreates a date from the given values; all parameters are optional.informat.Date.newDate(2025, 0, 3) // 2025-01-03 00:00:00.000
dateSetd: Date or Long, type: String, value: IntegerDateSets the specified field of the date to the given value.informat.Date.dateSet(date, 'year', 2024) // sets year to 2024
dateAddd: Date or Long, type: String, diff: IntegerDateAdds the given amount to the specified field of the date.informat.Date.dateAdd(date, 'year', 1) // adds 1 year
datePartd: Date or Long, type: StringIntegerExtracts the value of the specified field from the date.informat.Date.datePart(date, 'year') // returns the year
dateBefored1: Date or Long, d2: Date or LongBooleanReturns true if d1 is before d2.informat.Date.dateBefore(date1, date2) // true/false
dateAfterd1: Date or Long, d2: Date or LongBooleanReturns true if d1 is after d2.informat.Date.dateAfter(date1, date2) // true/false
dateDiffd1: Date or Long, d2: Date or LongIntegerCalculates the difference in days between two dates.informat.Date.dateDiff(date1, date2) // day difference
monthDiffd1: Date or Long, d2: Date or LongIntegerCalculates the difference in months between two dates.informat.Date.monthDiff(date1, date2) // month difference
weekDiffd1: Date or Long, d2: Date or LongIntegerCalculates the difference in weeks between two dates.informat.Date.weekDiff(date1, date2) // week difference
quarterDiffd1: Date or Long, d2: Date or LongIntegerCalculates the difference in quarters between two dates.informat.Date.quarterDiff(date1, date2) // quarter difference

Special Notes

month Value range

MonthValue
10
21
32
43
54
65
76
87
98
109
1110
1211

day_of_week Value range

DayValue
Sunday0
Monday1
Tuesday2
Wednesday3
Thursday4
Friday5
Saturday6

Encode

String encoding and decoding functions; invoked as informat.Encode.method.

MethodParametersReturn TypeDescriptionExample
md5s: StringStringReturns the MD5 hash value of the string.informat.Encode.md5('123456') // e10adc3949ba59abbe56e057f20f883e
urlEncodestr: StringStringEncodes the string for use in a URL.informat.Encode.urlEncode('https://next.informat.cn') // https%3A%2F%2Fnext.informat.cn
urlDecodestr: StringStringDecodes 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.

MethodParametersReturn TypeDescriptionExample
absx: Integer或DoubleInteger或DoubleReturns the absolute value of the number.informat.Math.abs(-100.3) // 100.3
powd1: Integer或Double, d2: Integer或DoubleDoubleReturns d1 raised to the power of d2.informat.Math.pow(2, 3) // 8.0
ceilx: DoubleDoubleReturns the smallest integer greater than or equal to x.informat.Math.ceil(2.2) // 3.0
floorx: DoubleDoubleReturns the largest integer less than or equal to x.informat.Math.floor(2.2) // 2.0
randomNoneDoubleReturns a random number between 0 and 1.informat.Math.random() // 0.6260832016946124
sqrtx: DoubleDoubleReturns the square root of x.informat.Math.sqrt(4) // 2.0
roundn: Double, digits: IntegerDoubleRounds 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.

MethodParametersReturn TypeDescriptionExample
jsonStringifyobj: ObjectStringConverts an object to a JSON string.informat.Misc.jsonStringify({a:1}) // "{\"a\":1}"
jsonParsestr: StringObjectConverts a JSON string to an object.informat.Misc.jsonParse('{"a":1}') // {a:1}
parseFloatstr: StringDoubleConverts a string to a floating-point number.informat.Misc.parseFloat("3.14") // 3.14
parseIntstr: StringIntegerConverts a string to an integer.informat.Misc.parseInt("3.14") // 3
timestampToDatetimestamp: IntegerDateConverts a UNIX timestamp to a date.informat.Misc.timestampToDate(1667232000000)
dateToTimestampdate: DateIntegerConverts a date to a UNIX timestamp.informat.Misc.dateToTimestamp(new Date())
formatDatedate: Date, fmt: StringStringFormats the date according to the specified format.informat.Misc.formatDate(date, 'yyyy-MM-dd')
parseDatestr: String, fmt: StringDateParses a date string according to the specified format.informat.Misc.parseDate('2022-11-01', 'yyyy-MM-dd')
hostNoneStringReturns the system home page address.informat.Misc.host() // https://next.informat.cn/
pinyinstr: StringStringReturns the pinyin of the string.informat.Misc.pinyin('你好') // "ni hao"
shortPinyinstr: StringStringReturns the first letter of the pinyin.informat.Misc.shortPinyin('你好') // "nh"
expectNotNullobj: Object, message: StringObjectChecks if the object is not null; throws an exception if it is null.informat.Misc.expectNotNull(obj, '不能为空')
expectFirstarray: Array, message: StringObjectReturns the first element of the array.informat.Misc.expectFirst([1,2], '空数组') // 1
expectLastarray: Array, message: StringObjectReturns the last element of the array.informat.Misc.expectLast([1,2], '空数组') // 2
invokeScriptscript: String, func: String, ...args: ObjectObjectInvokes a function in the specified script.informat.Misc.invokeScript('test.js', 'add', 1, 2)
invokeAutomaticautomaticId: String, ...args: ObjectObjectInvokes an automatic program.informat.Misc.invokeAutomatic('test', 1, 2)
httpGeturl: StringStringAccesses the URL using the GET method.informat.Misc.httpGet('https://example.com')
propobject: Object, key: StringObjectReturns the value of the specified property.informat.Misc.prop({a:1}, 'a') // 1
propsobject: Object, props: Array<String>ObjectReturns a new object with the specified properties.informat.Misc.props({a:1,b:2}, ['a'])
transformobject: Object, mapping: Map<String,String>ObjectTransforms the object properties according to the mapping relationship.informat.Misc.transform({name:'张三'}, {name:'userName'})
appIdNoneStringReturns the ID of the current application.informat.Misc.appId()
getAppIdByKeykey: StringStringReturns the application ID by the application key.informat.Misc.getAppIdByKey('appKey')
attachmentURLtableKey: String, fieldKey: String, value: StringStringReturns the attachment access link.informat.Misc.attachmentURL('staff','photo','1.png')
appResURLappResId: StringStringReturns the application resource library resource address.informat.Misc.appResURL('image.jpg')
websiteResURLmoduleKey: String, filePath: StringStringReturns the website module resource address.informat.Misc.websiteResURL('module','logo.png')
barcodeURLvalue: String, format: StringStringReturns the barcode image BASE64 value.informat.Misc.barcodeURL('12345','CODE128')
qrcodeURLvalue: String, width: IntegerStringReturns the QR code image BASE64 value.informat.Misc.qrcodeURL('text', 300)
evalstr: String, context: ObjectObjectEvaluates the expression engine template.informat.Misc.eval('${name}', {name:'test'})
safesqlsql: String, params: Array<Object>StringGenerates a safe SQL statement with parameter placeholders.informat.Misc.safesql('select ?', ['test'])
uuid16NoneStringGenerates a 16-character UUID string.informat.Misc.uuid16() // "lqjfw3xaglp38tru"
uuid32NoneStringGenerates a 32-character UUID string.informat.Misc.uuid32() // "rigzv6usysisu2gmkash6hdg526y10b5"
newObjectNoneObjectBuilds an empty object.informat.Misc.newObject() // {}
recordSqlsql: 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.

MethodParametersReturn TypeDescriptionExample
usersWithRoleroleIdList: Array<String>Array<String>Returns a list of users who have any of the specified roles.informat.User.usersWithRole(['admin']) // [user1, user2, user3]
usersWithDepartmentdepartmentIdList: Array<String>Array<String>Returns a list of users who belong to any of the specified departments.informat.User.usersWithDepartment(['yanfabu'])
superiorUsersuserId: StringArray<String>Returns a list of direct superior users of the specified user.informat.User.superiorUsers('user1') // [user2, user3]
superiorUsersWithLeveluserId: String, level: IntegerArray<String>Returns a list of direct superior users of the specified user up to the specified level.informat.User.superiorUsersWithLevel(Context.userId(), 1)
subordinateUsersuserId: StringArray<String>Returns a list of direct subordinate users of the specified user.informat.User.subordinateUsers('user1') // [user2, user3]
subordinateUsersWithLeveluserId: String, level: IntegerArray<String>Returns a list of direct subordinate users of the specified user up to the specified level.informat.User.subordinateUsersWithLevel('user1', 2) // [user2, user3]
leaderOfDeptdepartmentId: StringArray<String>Returns a list of direct department leader users for the specified department.informat.User.leaderOfDept('dept1') // [user2, user3]
leaderOfDeptWithLeveldepartmentId: String, level: IntegerArray<String>Returns a list of direct department leader users for the specified department up to the specified level.informat.User.leaderOfDeptWithLevel('yanfabu', 1)
leaderOfDeptListdepartmentIdList: Array<String>Array<String>Returns a list of direct department leader users for the specified departments.informat.User.leaderOfDeptList(['dept1', 'dept2']) // [user2, user3, user4]
parentOfDeptdepartmentId: StringStringReturns the direct parent department ID of the specified department.informat.User.parentOfDept('dept1') // dept2
parentOfDeptListdepartmentId: StringArray<String>Returns a list of all parent department IDs for the specified department.informat.User.parentOfDeptList('dept1') // ['dept2', 'dept3']
childrenOfDeptdepartmentId: StringArray<String>Returns a list of all child department IDs for the specified department (recursively).informat.User.childrenOfDept('dept1') // [dept2, dept3]
childrenOfDeptListdepartmentList: Array<String>Array<String>Returns a list of all child department IDs for the specified departments (recursively).informat.User.childrenOfDeptList(['dept1', 'dept2']) // [dept2, dept3]
directChildrenOfDeptdepartmentId: StringArray<String>Returns a list of all direct child department IDs for the specified department.informat.User.directChildrenOfDept('dept1') // [dept2]
useruserId: StringUserReturns a user information object.informat.User.user(Context.userId())
userInfouserId: StringUserInfoReturns a user detailed information object.informat.User.userInfo(Context.userId())
deptListdepartmentIdList: Array<String>Array<Dept>Returns a list of department information objects.informat.User.deptList(['dept1', 'dept2'])
deptdeptId: StringDeptReturns a department information object.informat.User.dept('dept1')

Context

Context-related functions; invoked as informat.Context.method.

MethodParametersReturn TypeDescriptionExample
userIdNo ParametersStringReturns the ID of the current operating user.informat.Context.userId() // "ek5veueb6c9zg"
appIdNo ParametersStringReturns the ID of the current application.informat.Context.appId()
appEnvProppropKey: StringStringReturns the value of the specified application environment property.informat.Context.appEnvProp('payURL') // "http://dev-demo.com/pay"
httpHeadersNo ParametersObjectReturns the HTTP request header information.informat.Context.httpHeaders() // {headers: {...}}
clipboardTypeNo ParametersStringReturns the type of data stored in the application clipboard.informat.Context.clipboardType() // "test"
clipboardDataNo ParametersObjectReturns the data stored in the application clipboard.informat.Context.clipboardData()
weworkAccessTokenNo ParametersStringReturns the enterprise WeWork AccessToken.informat.Context.weworkAccessToken()
dingtalkAccessTokenNo ParametersStringReturns the DingTalk AccessToken.informat.Context.dingtalkAccessToken()
feishuAccessTokenNo ParametersStringReturns the Feishu application AccessToken.informat.Context.feishuAccessToken()
feishuTenantAccessTokenNo ParametersStringReturns the Feishu tenant AccessToken.informat.Context.feishuTenantAccessToken()
requestIpNo ParametersStringReturns the IP address of the current request.informat.Context.requestIp() // "192.168.1.1"
hasAppPermpermKey: StringBooleanReturns whether the current user has the specified application permission.informat.Context.hasAppPerm('admin') // true
hasModulePermmoduleKey: String, permKey: StringBooleanReturns whether the current user has the specified module permission.informat.Context.hasModulePerm('crm', 'read') // true

Record

Record-related functions; invoked as informat.Record.method.

MethodParametersReturn TypeDescriptionExample
getByIdtableId: String, recordId: StringObjectRetrieves a single record by ID.informat.Record.getById('order', 'z2koxrkxtp854') // {amount:11, name:'Test PO', id:'z2koxrkxtp854'}
getFieldValuetableId: String, recordId: String, fieldId: StringObjectReturns the value of the specified field in the record.informat.Record.getFieldValue('order','z2koxrkxtp854','amount') // 11
getByFieldtableId: String, fieldId: String, opt: String, value: ObjectArray<Record>Filters records by a single field condition.informat.Record.getByField('order', 'amount', 'eq', 11) // [{amount:11, name:'Test PO', id:'z2koxrkxtp854'}]
getByFieldstableId: String, conditions: ArrayArray<Record>Filters records by multiple field conditions.informat.Record.getByFields('tab', [{fieldId:'text', opt:'eq', value:'13'}]) // [{amount:11, text:'13', id:'z2koxrkxtp854'}]
getRecordOptionNametableId: String, fieldId: String, value: StringStringReturns the display name of a single option value.informat.Record.getRecordOptionName('order', 'type', 'a') // "Option 1"
getRecordOptionNamestableId: String, fieldId: String, valueList: Array<String>, join: StringStringReturns the display names of multiple option values, joined by the separator.informat.Record.getRecordOptionNames('order', 'type', ['a','b'], ',') // "Option 1, Option 2"
getRecordOptionstableId: String, fieldId: StringArray<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'}]
getRelationListtableId: String, fieldId: String, recordId: StringArray<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.

MethodParametersReturn TypeDescriptionExample
localeNo ParametersStringReturns the current language used for translation.informat.T.locale() // "zh-CN"
tkey: String, args: Object/ArrayStringTranslates the specified key using the current language and arguments.informat.T.t('welcome.message') // "欢迎"
tWithLocalelocale: String, key: String, args: Object/ArrayStringTranslates the specified key using the specified language and arguments.informat.T.tWithLocale('en-US', 'welcome.message') // "Welcome"