Run Microflow before validation

4
I have an entity with two attributes: a number (unique and required) and a caption Numbers should be incremental starting at 0 - I want to implement a microflow that allows the user to add a new object in the middle. Lets say I have 4 objects with number 0 to 3 and I want to add a new object with number 1 - I need to increment objects with number >= 1 by 1. I managed to createa microflow that deletes an objects and decrements the other objects to fill the gap. My problem with adding an object is that the validation check takes place before I can run the microflow. after create event does not hold any data that can be used hence microflow fails. if I create a button and set a breakpoint the microflow never starts as the validation comes first (firebug shows that the object is changed before the execution of microflow - I made sure that nothing commits or changes the object)
asked
3 answers
4

How about simply keeping a self-reference to the next object? That way, if you need to insert an object somewhere in the flow, you simply point the previous object to the new object, and the new object reference to the next object. In CS this is commonly referred to as a linked list, where every object has a reference to the next.

Looping through the stages would be as easy as simply retrieving the next association till the next association returns empty.

answered
4

It's probably best to remove the validation rules and check those in your microflow. This way you can get to your microflow and do all your activies and then validate it and if needed throw a Validation message from there.

answered
2

I still have to make sure that the stage-numbers are sequential, when adding a new object with number 2 for example, all the object that are equal or greater to 2 have to be incremented by one.

Solved it by removing unqiue requirement, retrieving all objects with stage-number equal or great to the new one and incrementing them by one. If I implement a linked list then not only do I have to maintain the self-reference but also amend the stage numbers.

Editing objects stage-number works by combining the delete microflow with the add microflow - however the delete behaviour that I have set up in the domain model breaks this sometimes.

So the user is allowed to create and delete an object with stage-number and caption. Editing is only possible in the form of changing the caption.

answered