This topic describes how to use advanced account field expressions in the IDaaS built-in expression engine and provides details about model fields, functions, and reference examples.
Basics
IDaaS has a built-in expression engine. In SAML and OpenID Connect (OIDC) applications, you can use advanced expressions to add new parameters to the returned user information. Use expressions if the target application requires additional parameters that need to be converted, concatenated, or evaluated.
Similarly, you can use the same method to customize field values with expressions when you configure field mappings for synchronization with an identity provider.
This topic provides reference examples to help you understand the scenarios and methods for using expressions.
For example, in an OIDC single sign-on (SSO) configuration, you can extend the returned id_token information. In the extension value, you can enter an advanced expression such as full_phone to achieve a specific processing goal.

For more information, see SAML attribute statement mapping rules, OIDC id_token extension value mapping rules, and Field management.
Expressions consist of two parts:
Models, which include User (for IDaaS accounts) and AppUser (for application accounts).
Functions, which represent logical operations.
Model descriptions
1. User
The following fields are in the IDaaS User model. You can reference them using formats such as user.username and user.lockExpireTime.
Field Display Name | Field ID | Data Type | Required | Unique | User Permissions | Description |
Account ID | userId | String | No | Yes | Visible | The user ID. |
Username | username | String | Yes | Yes | Visible | The username. |
Display name | displayName | String | No | No | Editable | The user's display name. |
String | No | Yes | Editable | The email address. | ||
Mobile phone | phoneNumber | Number | No | Yes | Editable | The phone number. |
Phone area code | phoneRegion | Number | No | No | Editable | The area code for the phone number. Example: The area code for China is "86", without "00" or "+". |
External ID | userExternalId | String | No | Yes | Visible | The user's external ID. |
Source type | userSourceType | String | No | No | Visible | The source type. Valid values:
|
Source ID | userSourceId | String | No | No | Visible | The source ID. |
Account status | status | String | No | No | Visible | The user status. Valid values:
|
Description | description | String | No | No | Visible | The description. |
Account expiration time | accountExpireTime | Number | No | No | Visible | The time when the user account expires. This is a UNIX timestamp in milliseconds. |
Account registration time | registerTime | Number | No | No | Visible | The time when the user registered. This is a UNIX timestamp in milliseconds. |
Password expiration time | passwordExpireTime | Number | No | No | Visible | The time when the password expires. This is a UNIX timestamp in milliseconds. |
Lock expiration time | lockExpireTime | Number | No | No | Visible | The time when the lock expires. This is a UNIX timestamp in milliseconds. |
Creation time | createTime | Number | No | No | Visible | The time when the account was created. This is a UNIX timestamp in milliseconds. |
Update time | updateTime | Number | No | No | Visible | The time when the user information was last updated. This is a UNIX timestamp in milliseconds. |
2. App User
The following fields are in the IDaaS AppUser model. You can reference them using a format such as appUser.username.
Property | Description |
username | The username of the application account. |
3. IdP User
The IdP User model is used for synchronization with an identity provider. For example, the office location field for DingTalk is idpUser.work_place.
For specific fields, see the documentation for the corresponding identity provider, such as the DingTalk Help Document - User Details.
For OIDC identity providers (see Attach an OIDC identity provider), when you use expressions in the automatic attachment feature, the idpUser. prefix applies only to the sub, phoneNumber, and email fields from the id_token (for example, idpUser.sub). For all other fields, you must use the idpUser.rawUserInfo. prefix (for example, idpUser.rawUserInfo.aud).
Function descriptions
The following table describes the available functions and provides examples:
Function name | Function definition | Description | Example |
Append | Append(str1, str2, ..., strn) | Concatenates the input parameters into a new string. This is equivalent to |
|
Join | Join(source1, source2, ..., sourceN, separator) | Joins multiple source values into a single string, separated by the specified separator. |
|
Coalesce | Coalesce(source1, source2, ..., sourceN, defaultValue) | Returns the first non-empty parameter from the input. If all parameters are empty, it returns null. A non-empty parameter is not null and has a length greater than 0. |
|
IIF | IIF(condition, whenTrue, whenFalse) | Ternary operation. Returns a value based on the result of the condition. If the condition is true, it returns whenTrue. If the condition is false, it returns whenFalse. | Example 1:
Example 2:
|
IsNull | IsNull(value) | If the value is null or missing, the output is true. | Example 1:
Example 2:
|
IsNullOrEmpty | IsNullOrEmpty(value) | If the value is null or an empty string, the output is true. | Example 1:
Example 2:
|
Now | Now() | Returns a string representing the current UTC DateTime in the yyyy-MM-dd'T'HH:mm:ssXXX format. |
|
StringReplace | StringReplace("hello $VariableName", "$VariableName", ReplaceString) | Performs a simple string replacement. |
|
Trim | Trim(source) | Removes leading and trailing whitespace characters from the source string. |
|
TrimLeft | TrimLeft(source) | Removes leading whitespace characters from the source string. |
|
TrimRight | TrimRight(source) | Removes trailing whitespace characters from the source string. |
|
ToLower | ToLower(source) | Converts a string to all lowercase. |
|
ToUpper | ToUpper(source) | Converts a string to all uppercase. |
|
Substring | Substring(source, fromIndex, endIndex) | Returns a substring of the string. The substring starts at fromIndex and ends before endIndex.
| Example 1:
Example 2:
Example 3:
|
SubstringBefore | SubstringBefore(source, subString) | Searches a source string from left to right for a target string and returns the substring that follows the first occurrence. If the target string is not found, null is returned. Parameters:
Return value: string | Example 1:
|
Array | Array(source1, source2,...) | Combines multiple values into an array. The values can be of the Object type. |
|
ArrayAdd | ArrayAdd(Array(), "test") | Adds an element to an array object. |
|
ArrayMap | ArrayMap($ArrayObject, __item.ObjectProperty) | Creates a new array with the values of a specific property from an array of objects. | Get a list of group IDs for a user:
|
ArrayIndex | ArrayIndex(Array(), n) | Gets the element at a specific index in an array. The index starts from 0. |
|
ArrayJoin | ArrayJoin(Array(), str) | Joins the elements of an array into a string, using a specified separator. |
|
Object | Object(key1, value1, key2, value2, ...) | Creates an Object by combining key-value pairs. Supports zero or an even number of parameters. |
|
ObjectIndex | ObjectIndex(user, "username") | Gets the value of a specific property from an object. | The code |
ObjectToJsonString | ObjectToJsonString(user.groups) | Converts an object to a JSON string. | - |
Contains | Contains(str1,str2) | Checks if a string contains another string. Returns true or false. | Example 1:
Example 2:
|
Or | Or(true,false,...,true) | Performs a logical OR operation on multiple conditions. If any condition is true, the result is true. | Example 1:
Example 2:
Example 3:
|
And | And(true,false,...,true) | Performs a logical AND operation on multiple conditions. If any condition is false, the result is false. | Example 1:
Example 2:
Example 3:
|
xOr | xOr(true,false,...,true) | Requires exactly two conditions. Returns false if both conditions are true or both are false. Returns true if one condition is true and the other is false. | Example 1:
Example 2:
Example 3:
|
StartsWith | StartsWith(str1, str2) | Checks if a string starts with a specified prefix. This function takes exactly two parameters. | Example 1:
Example 2:
|
Split | Split("str1,str2,str3") | Splits a string into an array of substrings. | Example 1:
|
Equals | Equals(str1,str2) | Compares two strings for equality. Equals(str1,str2). Equals(str1,str2,false) performs a case-sensitive comparison. Equals(str1,str2,true) performs a case-insensitive comparison. | Example 1:
Example 2:
Example 3:
|
CurrentTimeMillis | CurrentTimeMillis() | The current UNIX timestamp in milliseconds. | - |
SamlArray | SamlArray(Array()) | Available only for SAML SSO. | Input:
<saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:type="xsd:string"> group1 group2
|
ExtractPhoneRegion | ExtractPhoneRegion(source, defaultRegion,autoAppendPlusSignal) | Extracts the area code from a phone number.
| Example 1: If the phone number is
Example 2: If the phone number is
Example 3: If the phone number is
|
ExtractPhoneNumber | ExtractPhoneNumber(source, defaultRegion,autoAppendPlusSignal) | Extracts the phone number without the area code.
| Example 1: If the phone number is
Example 2: If the phone number is
Example 3: If the phone number is
|
Reference examples
Result | Example expression |
Get the username and append the fixed string "@example.com". |
|
If the email is not empty, return the email. If the email is empty, return the phone number. |
|
If the phone number is empty, use a fixed phone number as the default. |
|
Concatenate the phone area code and the phone number with a hyphen (-). |
|
Return a custom welcome message that includes the display name. |
|
Mask the middle four digits of the phone number with asterisks (*). |
) |
Extract the username from the email address. |
|
Assemble the email field in the array format specified by the System for Cross-domain Identity Management (SCIM) protocol. |
|
User model JSON example:
{
"customFieldMap": {
"place": {
"fieldName": "place",
"fieldValue": "beijing"
},
"age": {
"fieldName": "age",
"fieldValue": "18"
}
},
"identityProviderUserMap": {
"idp_m2gngriuenktdkxxxxxx": {
"identityProviderId": "idp_m2gngriuenktdkxxxxxx",
"identityProviderType": "ding_talk",
"identityProviderExternalId": "corp_1234xxxxxxx",
"identityProviderUserId": "b2ed5fc0xxxxx"
}
},
"organizationalUnits": [
{
"organizationalUnitId": "ou_sdfadtaaxxxxxx",
"organizationalUnitName": "name_001",
"primary": false
},
{
"organizationalUnitId": "ou_werttxxxxxx",
"organizationalUnitName": "name_002",
"primary": true
}
],
"primaryOrganizationalUnitId": "ou_werttxxxxxx",
"customFields": [
{
"fieldName": "place",
"fieldValue": "beijing"
},
{
"fieldName": "age",
"fieldValue": "18"
}
],
"groups": [
{
"groupId": "group_jp6al4sn4n4wjgjxxxxxx",
"groupName": "group1",
"groupExternalId": "group_jp6al4sn4n4wjgjxxxxxx"
},
{
"groupId": "group_vavikcxewkf5h3oxxxxxx",
"groupName": "group2",
"groupExternalId": "group_vavikcxewkf5h3oxxxxxx"
}
],
"userId": "user_x3zyd6cxxxxxxxxxxxxx",
"username": "name_001",
"displayName": "displayname_001",
"passwordSet": true,
"phoneRegion": "86",
"phoneNumber": "333xxxx3333",
"phoneNumberVerified": true,
"email": "xxxxx@example.com",
"emailVerified": true,
"userExternalId": "b2ed5fc0xxxxxxxxxx",
"userSourceType": "ding_talk",
"userSourceId": "corp_1234xxxxxxx",
"status": "enabled",
"accountExpireTime": "-1",
"passwordExpireTime": "-1",
"registerTime": "1730454581598",
"lockExpireTime": "-1",
"createTime": "1730454582379",
"updateTime": "1733479455307"
}