Hello , I have a problem , in my entity there are so many repetative data for example (“Apple”,”Apple”) just like that , now from microflow when I retrieve the data from Entity I want to retrieve only one data “Apple” not more than this .I don’t want to use rules validation unique in entity . I want to handle that from microflow . Is there any simple microflow or documentation please give me the link.
You need to validate the uniqueness of a certain attribute of an object when it is created (e.g. when the data is entered by the user). Let’s say you have an entity Fruit, and this entity has 1 attribute Name. Let’s say that you want to add a new fruit, you will click on “New”, and a popup with the details of the fruits appears so that you can enter the data of the fruit. You enter “Apple” in the Name TextBox. When you click on the Save button, you need to do a retrieve from Database and set the entity type to Fruit, and the XPath should look something like this (this is case sensitive, if you want case insensitive you should use toLowerCase on $Fruit/Name in a temporary variable and use the temporary variable instead of $Fruit/Name): [Name = $Fruit/Name]. This checks whether there is an object in the database that has the same Name value.
Now, for removing the duplicated data. There is no easy solution, so you need to clean this data yourself. You need to create a microflow that cleans the data. The image of the microflow below provides an example of how to clean the data. Firstly, you need to retrieve all the fruits objects (AllFruitList) and create a list that should be deleted (DuplicatedFruitList_ToBeDeleted).
You then need get the HeadFruit (first object) object → remove the head object from AllFruitList → filter AllFruitList based on HeadFruit’s Name attribute (name the DuplicatedFruitList) → add DuplicatedFruitList to DuplicatedFruitList_ToBeDeleted → Remove DuplicatedFruitList from AllFruitList. Then you need to repeat the process until there are no objects in AllFruitList.
Short answer: this is not possible directly in a microflow, can be done with a java action and an OQL query.
Check the following answer for more details: https://forum.mendixcloud.com/link/questions/90820
SELECT DISTINCT Module.Project.Fruit FROM Module.Project