Microflow for checking if something already exists

Hi, I am developing a small online store in Mendix. I have a page called Categories, where I can enter new categories. I also have a button called “New”, that opens a pop-up for adding a new item in the Categories list and a “Save” button in this pop-up, but I want to have a condition for this Save button: when entering a new category, if that category already exists, I want to get a message that warns me that this category already exists. If everything is fine, I want to have the category added to the list. How should look the microflow (especially the decision activity)? Thank you! I will attach here screenshots with the domain model, the Categories page and the pop-up for adding a new category.   
3 answers

When you click on the save button, run it through a validation microflow to check if the category already exists in db. 


Hi Valentin,

You can use a database retrieve to check if the category with the same name already exists.

So add a retrieve from database, check first, set as xpath something like [Name = $Category/Name]

Lets call the return value Category_Existing


If this retrieve returns empty, you know it does not exist yet. If it is not empty, it exists already.


The decision would look like this: $Category_Existing = empty

The true-flow of the decision will continue to commit the new category, while the false flow will show a message to the user.


Hi Valentin,

I think you will want to follow a standard Validation microflow set-up


  1. When saving call a validation subflow
  2. You give the new category as a parameter
  3. Create a variable ‘valid’ (boolean)
  4. Retrieve categories from the database, with xPath: Name = $newCategory/name
  5. Add a decision: $retrievedCategory = empty. 
  6. If true, return $valid
  7. If false, Set $valid to false. Show validation feedback on name and merge back to the mainflow (With valid being false)
  8. In your save microflow: Check if $valid = true, if so commit the object and close. If false go to the end event without further actions. The user will see the validation feedback you made earlier.