Array Manipulation and Syntax Improvements
The latest version introduces several key enhancements to array handling:
- Array Appending: Easily add elements to arrays using the new
[]
syntax - Dynamic Key Access: Create and access array elements using dynamic keys and expressions
- Null-Coalescing Operator: Safely handle potentially non-existent array elements
Array Append Example
$list = list();
$list[] = 'a'; // Appends 'a' to the list
Enhanced Expression and Variable Handling
EspoCRM 9.1.0 introduces more intuitive ways to work with variables and expressions:
- Automatic Return: The last expression in a formula is now automatically returned
- Increment/Decrement Operators: Simplified variable manipulation with
++
and--
- Nested Object and Array Access: Easily navigate complex data structures
Return Expression Example
$a = 1;
$b = $a + 1;
$b; // Returns 2
Increment/Decrement Example
$a = 1;
$a++; // Increments $a to 2
$a--; // Decrements $a back to 1
Practical Applications
These new Formula features provide more flexibility in:
- Dynamic data processing
- Conditional logic implementation
- Complex calculations and transformations
Note: Reading a non-existent key will result in an error, but you can use the null-coalescing operator to provide a default value:
$list = list();
$v = $list[0] ?? 0; // Returns 0 if the key doesn't exist

How to test formulas?
You can always test formulas before you implement them inside Formulas sandbox.
Summary
These improvements make EspoCRM’s Formula functionality more powerful and user-friendly, enabling more sophisticated custom logic and data manipulation. You can check out other formulas in official documentation.