How do you determine that there is an endless loop: did you debug your microflow? Do you actually see that there is an "endless" loop? How many objects are returned by the webservice? Is anything returned at all?
And: do not commit the newly created object in the inner loop, but commit the list instead.
Hi Ivan,
In the screenshot, you are only showing the nanoflow. What is happening inside the microflow?
You mentioned that the web service returns two nested lists. Do you mean that the list contains two different objects?
Also, when you say there is an infinite cycle, what exactly do you mean? Is the loop inside the microflow running infinitely, or is the microflow itself being triggered repeatedly?
If the microflow is running continuously, one possible reason could be that you are refreshing the page parameter object (TranscriptCarrerasEstudiante) inside the microflow. That could cause the nanoflow to trigger the microflow again, resulting in an infinite loop.
Hi,
From what you described, the issue is not really an “infinite loop” in the microflow itself. The problem usually happens when a nanoflow keeps triggering the same microflow again because the widget reloads repeatedly.
The key detail in your case is this part:
You said you are calling the microflow from a nanoflow so the result can be used in a ListView.
When a nanoflow is used as the data source or refresh trigger of a widget, and that nanoflow calls a microflow that creates/changes objects, the UI refresh can cause the nanoflow to run again. That results in this cycle:
This repeats continuously and looks like an infinite loop.
Another common cause is when the microflow creates new objects each time instead of returning existing ones. Since the dataset changes every time, the ListView keeps refreshing and triggering the nanoflow again.
The usual way to solve this is:
Option 1
Do not call the microflow through a nanoflow for the ListView. Instead set the ListView data source directly to the microflow.
Example:
ListView → Data source → Microflow
Microflow → MC_TranscriptMaterias
This way the microflow runs once when the widget loads.
Option 2
If you must call it from a nanoflow, make sure the microflow only retrieves existing data and does not create new objects every time.
Option 3
Store the result in a helper object (non-persistable entity) and bind the ListView to that object instead of repeatedly executing the microflow.
In most Mendix projects the cleanest solution is simply to use the microflow as the ListView data source rather than calling it through a nanoflow. That prevents the UI refresh cycle that causes the repeated execution.