Old list still present on datagrid even though it was cleared

Hello! I am having an issue in a microflow:  So I have a list of tasks that will be changed to the boolean "iscompleted" true. On my microflow I am first retriveing that old list, then creating a new one, then follows the loop iterating through the old list and adding those to the new list. I end with a commit since I want those elements of the new list in my database for further work. The problem here is the datagrid and database do not show the tasks correctly, because they create new tasks from the old ones but the old ones are still there.  I have tried clearing the old list, but the problem persists. Thanks for the help!
2 answers

It seems to me that you are going about this in the wrong way.

If you have a list of items and you want to change their attributes (boolean) to true, you would only want to create a new list if you only want to change a subset of these items to true rather than all of the items in the old list. Since Mendix is Java-based in Microflows, you can change the attribute of these objects directly from within the old list during the iteration.


If you do need to only change a subset of these items, then make sure that when you change the attributes and add the items to the new list, that you don't create new objects. An object can be part of multiple lists, so creating new objects would not be necessary. I am mentioning this, as such an implementation would lead to the behavior you are describing.


Finally, make sure that you commit the new list after iterating through the old list and adding items to the new list. Additionally, make sure to toggle "refresh in client" when committing this list.


Finally, if you are still experiencing issues, have a look at how your datasource of the datagrid is configured. Sometimes, if it is nested to deep, or if the datagrid is configured to obtain these items through indirect sources rather than specifying a database or xpath data source, it can show strange behaviour regarding refreshes from my experience. You can test if this is the case by reloading the page in the browser and verifying that the old data is still there on reload.


Really helpful, thanks a lot! I was stuck in this for a while and now I understand what was going wrong.