Mendix 7 is no longer supported unless you have Extended Support (for details, please contact Mendix Support). Mendix 7 documentation will remain available for customers with Extended Support until July, 2024.
Expressions
Expressions can for example be used to change a member of an object based on logic. Variables in the microflow can be called in an expression by inserting the name of the variable and adding a dollar sign. E.g. $customer refers to the variable customer. Expressions can be used recursively, for example, 1 + 2 + 3. Attributes and associations of object variables are accessed using a slash, for example, $customer/Name, $customer/CRM.Customer_Order.
To illustrate this imagine an object with variable name package with two attributes: weight (Float) and shippingCosts(Decimal). Rule: if the weight of a package is less than one kilogram there are no shipping costs. Otherwise the shipping costs are €5.00. The expression for changing attribute shippingCosts is: if $package/weight < 1.00 then 0.00 else 5.00.
An overview of the possibilities with expressions can be found below.
Unary Expressions:
Arithmetic Expressions:
Relational Expressions:
- Less than ( < )
- Greater than ( > )
- Less than or equal to ( <= )
- Greater than or equal to ( >= )
- Is equal to ( = )
- Is not equal to ( != )
Special checks
- Checking for an empty object
- Checking for an empty object member
isNew
- Checking whether an object is new
Boolean expressions
If expressions
Mathematical function calls
max
- Maximum of a list of numbersmin
- Minimum of a list of numbersround
- Rounding a floating-point number, optionally to a specified precisionrandom
- Random number generationfloor
- Rounding a floating-point number downceil
- Rounding a floating-point number uppow
- Exponentiationabs
- Absolute valuefloatsEqual
/ currenciesEqual
- Equality of floats/currencies for a certain precision (deprecated)
String function calls
toUpperCase
- Convert string to uppercasetoLowerCase
- Convert string to lowercaselength
- String lengthsubstring
- Get part of a stringfind
- Get substring positionfindLast
- Get last substring positioncontains
- Contains substringstartsWith
- Determine whether a string starts with the specified substringendsWith
- Determine whether a string ends with the specified substringtrim
- Remove leading and trailing whitespaceisMatch
- Match regular expressionreplaceAll
- Replace occurrences of substringreplaceFirst
- Replace first occurrence of substring- String concatenation ( + ) - Concatenate strings
urlEncode
- Convert a string to be used in a URLurlDecode
- Convert a string back from a URL
Date creation
dateTime
- Creating a date value using the server’s calendardateTimeUTC
- Creating a date value using the UTC calendar
Between date function calls
millisecondsBetween
- Milliseconds between two datessecondsBetween
- Seconds between two datesminutesBetween
- Minutes between two dateshoursBetween
- Hours between two datesdaysBetween
- Days between two datesweeksBetween
- Weeks between two dates
Add date function calls
addMilliseconds
- Add milliseconds to a dateaddSeconds
- Add seconds to a dateaddMinutes
- Add minutes to a dateaddHours
- Add hours to a dateaddDays
- Add days to a dateaddDaysUTC
- Add days to a date using the UTC calendaraddWeeks
- Add weeks to a dateaddWeeksUTC
- Add weeks to a date using the UTC calendaraddMonths
- Add months to a dateaddMonthsUTC
- Add months to a date using the UTC calendaraddYears
- Add years to a dateaddYearsUTC
- Add years to a date using the UTC calendar
Trim to date
trimToSeconds
- Trim to secondstrimToMinutes
- Trim to minutestrimToHours
- Trim to hourstrimToHoursUTC
- Trim to hours using the UTC calendartrimToDays
- Trim to daystrimToDaysUTC
- Trim to days using the UTC calendartrimToMonths
- Trim to monthstrimToMonthsUTC
- Trim to months using the UTC calendartrimToYears
- Trim to yearstrimToYearsUTC
- Trim to years using the UTC calendar
To string
To float (deprecated)
Parse integer
Parse/format float function calls (deprecated)
parseFloat
- Convert a string to a floatformatFloat
- Convert a float to a string
Parse/format decimal function calls
parseDecimal
- Convert a string to a decimalformatDecimal
- Convert a decimal to a string
Parse/format date function calls
parseDateTime[UTC]
- Convert a string to a date valueformatDateTime[UTC]
- Convert a date value to a stringformatTime[UTC]
- Convert the time part of a date value to a stringformatDate[UTC]
- Convert the date part of a date value to a string
Enumerations in expressions
getCaption
- Get caption of enumeration value in current languagegetKey
- Get technical name of enumeration value