Use of a loop

Hi everybody, I am trying to check in a microflow the unicity of an entity attribute when I create it. Before I tried to make it unique in the data model but it didn't work very well and I could'nt see why, so I prefer trying like this. The first thing that I do is to create a list that contains the objects that I want to compare to the new one created.  Afterwards I try to do something like a foreach in programmation : For each Object of the list, I want to compare his name attribute to the name attribute of the objet that I create. - If it is true, I display an error message and let the user change the name (blocking by this way the object creation.  - If it is false, I do nothing and let the application create the object as wanted. It is this last part that causes me problems, because I try to put an exclusive split into my loop, but I can't link it to the following of my flow...   Could you help me for this issue ? 
4 answers

It seems like the objects you are comparing with are stored in the database. You could do it without a loop and only retrieve a list of objects by xpath.

Something like:
[attribute = $MyProgram/attribute]

If this returns an empty list, there is no object with this value in the database and you are good to go.

This solution should be much faster on larger datasets.


Hi Dan,

The exclusive split would just need to be the first activity in your loop. If its true use the show message activity, if its false use the continue event.


I would also check out the learning modules.


Hope this helps!



Thank you very much for the answer. I tried exactly like you adviced, and it almost works. I just miss something when I display the error message, I would want to return false. And I don't know how to do it. 

Here is what I have done (MyProgram is the name of my object).


I tried without the loop and with the Xpath constraint [attribute = $MyProgram/attribute] to test the existence of a program with the same name. It works perfectly, the only problem that I have now is that I would like to allow the user to retype a different value. Instead of that the creation of the object stops completly and we go back to the menu page. 

How could I do this please ? 

PS : I tried 2 ways, first by adding this microflow into an activity of the object creation microflow, and second by creating an event handler in the model before the commit. But in both cases I don't manage to do exactly what I want.