This page is an overview of all the elements that can be used in a nanoflow. For the properties of the nanoflow itself, see Nanoflow Properties.
Nanoflows are similar to microflows, as they allow you to express the logic of your application. However, they do have some specific benefits (for example, they run directly on the browser/device and can be used in an offline app). Furthermore, most of the actions run directly on the device, so there is also a speed benefit.
2 When to Use Nanoflows
2.1 Offline Mobile Apps
Nanoflows are designed with offline-first applications in mind, as they allow you to model application logic that works in offline apps. Since all database-related actions will be executed on the local offline database, nanoflows in offline apps will be super fast.
2.2 Logic Where No Connection Is Needed
Nanoflows also offer great value to online applications (for example, for UI logic, validations, calculations, and navigation). However, please keep in mind that, when you perform database-related actions, each action will create a separate network request to the Mendix Runtime.
The following actions interact with the database:
Therefore, the best practice is to use nanoflows in online applications when they do not contain the above actions.
Changing objects without committing is not a database-related action, as changes are applied on the device or in the browser.
2.3 Other Cases
The previous section stated that nanoflows perform best in online applications when no database-related actions are used, and these are generally the best cases. However, nanoflows that contain at most one database-related action can also still perform well. Because such nanoflows only require one network call, they perform as well as a microflow. An example of such a use case is performing validation logic on an object and committing the object in the same nanoflow.
3 Differences from Microflows
There are four main differences between nanoflows and microflows:
- When a nanoflow steps through its actions, client actions are directly executed. For example, an open page action immediately opens a page instead of at the end of the nanoflow. This is different from client actions in a microflow, which only run when the client receives the result from the microflow.
- When used in nanoflow activities, expressions do not support the following objects and variables:
- Nanoflows are not run inside a transaction so, if an error occurs in a nanoflow, it will not roll back any previous changes.
- Nanoflows and microflows do not provide the same actions. Some actions available in microflows are not available in nanoflows, and vice versa.
4 Keyboard Support
The nanoflow editor offers keyboard support for navigating and manipulating the nanoflows. The following table shows the keys that can be used.
|Arrow keys||Selects the nearby element (activity, event, loop, or parameter) in the direction of the arrow.|
|Enter||Edits the properties of the selected element.|
|F2||Renames the item returned by the selected element.|
|Shift + F2 or just starting to type||Edits the caption of the selected element.|
|Ctrl + arrow keys||Moves the selected element in the direction of the arrow.|
|Tab||If a loop is selected, the first element inside the loop is selected.|
|Shift + Tab||If an element inside a loop is selected, the loop itself is selected.|
|Home||Selects the start event.|
|End||Cycles through the end events.|
|Context-menu key or Shift + F10||Opens the context menu for the currently selected element.|
5 Notation & Categories
The graphical notation of nanoflows is based on the Business Process Model and Notation (BPMN). BPMN is a standardized graphical notation for drawing business processes in a workflow.
A nanoflow is composed of elements. The following categories are used:
- Events represent the start and endpoints of a nanoflow and special operations in a loop
- Flows form the connection between elements
- Decisions deal with making choices and merging different paths again
- Activities are the actions that are executed in a nanoflow
- Artifacts provide the nanoflow with input and allow comments to be made
Events represent the start and endpoints of a nanoflow and special operations in a loop.
|Start event||The starting point of the nanoflow. A nanoflow can only have one start event.|
|End event||Defines the location where the nanoflow will stop. Depending on the return type of the nanoflow, in some cases a value must be specified. There can be more than one end event.|
|Continue event||Used to stop the current iteration of a loop and continue with the next iteration. Please note that continue events can only be used inside a loop.|
|Break Event||Used to stop iterating over the list of objects and to continue with the rest of the flow after the loop. Please note that break events can only be used inside a loop.|
Flows form the connection between elements.
| | Sequence flow | An arrow that links events, activities, decisions, and merges with each other. Together they define the order of execution within a nanoflow. | | | Annotation flow | A connection that can be used to connect an annotation to another element. |
Decisions deal with making choices and merging different paths.
|Decision||Makes a decision based on a condition and follows one and only one of the outgoing flows. Please note that there is no parallel execution in nanoflows.|
|Merge||Can be used to combine multiple sequence flows into one. If a choice is made in a nanoflow and afterwards some common work needs to be done, you can combine the two (or more) paths using a merge.|
Activities are the actions that are executed in a nanoflow.
5.4.1 Object Activities
|Change object||Can be used to change the members of an object. This can be done with or without commiting.|
|Commit object(s)||Can be used to commit the changes to one or more objects.|
|Create object||Can be used to create an object.|
|Retrieve||Can be used to get one (or more) associated objects of another object. The activity can also get one (or more) objects directly from the database.|
|Rollback object||Can be used to undo the changes (that have not been committed) made to the object in the part of the nanoflow preceding the activity. This also deletes objects that have been created but never committed.|
5.4.2 List Activities
List activities can be used to create and manipulate lists of objects.
|Change list||Can be used to change the content of a list variable.|
|Create list||Can be used to create a (empty) list variable.|
5.4.3 Action Call Activities
|Call nanoflow||Can be used to call a nanoflow.|
5.4.4 Variable Activities
Variable activities can be used to create or change a variable within a microflow.
|Change variable||Can be used to change the value of a variable.|
|Create variable||Can be used to create a new variable.|
5.4.5 Client Activities
Client activities can be used to have the web client of your application perform an action, such as showing a different page or downloading a file.
|Close page||Closes the page that is opened last by the user that calls the microflow in which this activity is used.|
|Show page||Can be used to show a page to the user that calls the microflow in which this activity is used.|
|Validation feedback||Can be used to display red text below a widget that displays an attribute or association.|
|Loop||A looped activity is used to iterate over a list of objects. For every object the flow inside the looped activity is executed. A looped activity can contain all elements used in nanoflows, with the exception of start and stop events. The flow starts at the first element with no incoming flows.|
Artifacts provide the nanoflow with input and allow comments to be made.
|Parameter||Data that serves as input for the nanoflow. Parameters are filled at the location from which the nanoflow is triggered.|
|Annotation||An element that can be used to put comments in a nanoflow.|
6 Item Usages
Studio Pro visualizes which items are used by the selected element(s). It does this by showing the used items in white text on a blue background. Conversely, elements that use the item(s) returned by the selected element(s) are marked with the word ‘Usage’ in white text on a green background.
In the example below, the parameter AccountPasswordData is highlighted because it is used in the selected activity (Retrieve Account). And the activity Save password has a Usage label because it uses the object returned by Retrieve Account.
When an error occurs in a nanoflow, the changes that were made to objects are not rolled back and the nanoflow is aborted. Optionally, you can handle errors in the nanoflow itself by configuring an error handler. You can inspect the details of the error by looking at the
$latestError predefined variable.
7.1 Error Handlers
Error handlers are supported on all nanoflow elements except for gateways and loops. There are two error handler options:
- Abort (which is the default)
- Custom without rollback
With the Custom without rollback option, you can draw an additional flow from the block and then mark this flow as the error handler flow. The Custom without rollback option does not roll back the objects. After you select a flow as the error handler it will appear this way:
7.2 Error Inspection
In a custom error handler executed after an error occurs, the
$latestError variable is set to the message of the error information. The
$latestError variable type is
String, unlike in microflows where errors’ type is the
$latestSoapFault variable is not available in nanoflows.
8 Nanoflow Debugging
Step-by-step debugging is not supported yet. For now, we recommend using log message actions, which are shown in the console log of Studio Pro.
Nanoflows are executed in the context of the current user. Any operation for which the user is unauthorized will fail. For instance, when objects are retrieved in a nanoflow, only the ones for which the current user has read access will be returned. Committing an object only succeeds when the current user has write access for all changes.