Skip to content

Commit dc75fe4

Browse files
authored
Merge pull request #10501 from exec-astraea/mendix-11-empty-strings-handling
Mendix 11 Upgrade Guide: Empty Strings Handling
2 parents 722cf48 + 3014a82 commit dc75fe4

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

content/en/docs/refguide/installation/upgrading-from-10-to-11.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,74 @@ We recommend you also upgrade Atlas Web Content if it is in your app.
8181

8282
For optimal implementation, ensure all UI modules either use CSS variables or have their variables defined within the module. If an app uses CSS variables inside **theme/web/custom-variables.scss** while some UI modules still rely on old Atlas SASS variables, those usages will fallback to Atlas default values. Therefore, we recommend you to transition to CSS variables only after confirming that all company design modules no longer depend on Atlas SASS variables.
8383

84+
### Empty Strings Handling {#empty-strings-handling}
85+
86+
Historically, in Mendix we had an inconsistency in how we handled String type attributes and variables on the client side (for example, Nanoflows, Page expressions, widgets) and on the server side (for example, Microflows).
87+
88+
Consider the following expression:
89+
90+
```
91+
$NewEntity/Attribute = ''
92+
```
93+
94+
where `$NewEntity/Attribute` contains an `empty` value.
95+
96+
In a Nanoflow, this expression would be evaluated to `true` because, on the client side, we did not distinguish between empty strings `''` and an `empty` value.
97+
98+
In a Microflow, this distinction exists and the expression would yield `false`.
99+
100+
Moreover, on the client side a String attribute with a value set to `empty` would be treated as if it contains `''`. This made it impossible to check in a Nanoflow whether an attribute is `empty` or if it has an empty String value `''`.
101+
102+
In Mendix 11.0.0, we have made this behavior consistent. Now, strings are handled in the same way no matter where you use them.
103+
104+
We understand that this change might cause unexpected changes in existing applications migrated from older versions of Mendix.
105+
106+
We recommend carefully analyzing all expressions that are comparing strings against `''` or `empty` and doing extensive testing after the migration.
107+
108+
#### Example 1
109+
110+
Below is an example of a check that might lead to unexpected behavior.
111+
112+
```
113+
$NewEntity/Attribute = ''
114+
```
115+
116+
If you used this expression to check if an attribute of an object was not filled in, we recommend using the [trim](https://docs.mendix.com/refguide/string-function-calls/#trim) function. Trim will automatically convert `empty` to `''` and remove all surrounding whitespace in a string.
117+
118+
```
119+
trim($NewEntity/Attribute) = ''
120+
```
121+
122+
Alternatively, if you just want to check for `empty` and `''` you can rewrite it to:
123+
124+
```
125+
$NewEntity/Attribute = empty or $NewEntity/Attribute = ''
126+
```
127+
128+
#### Example 2
129+
130+
In case you want to compare your string attribute against `empty`, you only need to write
131+
132+
```
133+
$NewEntity/Attribute = empty
134+
```
135+
136+
In Mendix 11.0 you won’t run into any ambiguity around this anymore.
137+
138+
#### Example 3
139+
140+
```
141+
$User/Name + "@mendix.com"
142+
```
143+
144+
In this example, Mendix will handle string concatenation correctly no matter if `$User/Name` is `empty` or `''`. The resulting string will be `@mendix.com`.
145+
146+
In this particular example, if you want to prevent the generation of email addresses without the first part you should add a validation check before doing concatenation:
147+
148+
```
149+
if trim($User/Name) = '' then '' else $User/Name + "@mendix.com"
150+
```
151+
84152
### Using the **ShowHomePage** Microflow in the **System** Module {#apply-entity-access}
85153

86154
In Studio Pro versions prior to 11, the default configuration was insecure: **Apply entity access** was set to `false`. In Studio Pro version 11, the **ShowHomePage** microflow in the **System** module now enforces a secure default for entity access. As a result, after upgrading to version 11, your application may report errors that were previously not detected.
@@ -111,6 +179,5 @@ You can resolve the error by enabling entity access for the microflow that calls
111179
* We fixed the issue where SELECT * in combination with UNION and ORDER BY would fail on most database engines.
112180
* When COALESCE function in OQL has attributes of different numeric types, the result type is defined according to type precedence. Before, the result type would match the type of the first argument.
113181
* Client API `mx.logger` is no longer supported. All calls to it should be replaced with standard `console.log`, `console.warn`, and other such standard calls. All widgets that use the `mx.logger` need to be updated.
114-
* We no longer convert `empty` values sent to the client into empty strings. All client side expressions must be adjusted accordingly.
115182
* We no longer support the runtime API class `com.mendix.modules.email.EmailModule` which was deprecated in [Mendix 10.12](https://docs.mendix.com/releasenotes/studio-pro/10.12/#deprecate-email). We recommend using the [Email Connector](https://marketplace.mendix.com/link/component/120739) module instead.
116183
* The [Deep Link module](https://marketplace.mendix.com/link/component/43) is deprecated, and no longer receives active support starting with Studio Pro 11. The functionality this module offers has been replaced with built-in features of the Mendix Platform, such as Page URLs and Microflow URLs. Refer to the [Migrating to Page and Microflow URLs](/appstore/modules/deep-link/#migrate-page-micro) section in *Deep Link* for details on how to migrate to these built-in features.

content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/_index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ Below presents a list of main differences between microflows and nanoflows:
3535
* When used in nanoflow activities, expressions do not support the following objects and variables: `$latestSoapFault`, `$latestHttpResponse`, `$currentSession`, `$currentUser`, `$currentDeviceType`.
3636
* Nanoflows are not run inside a transaction. So, if an error occurs in a nanoflow, it will not roll back any previous changes.
3737
* <a id="list-changes-in-sub-nanoflows"></a>Changes done to the lists in a sub-nanoflow are not reflected in the original nanoflow.
38-
* In nanoflows, when retrieving an `empty` attribute of an object, an empty string (`''`) is returned.

0 commit comments

Comments
 (0)