Aware IM is an amazing tool in so many ways as you all know.
But, what many don't know is that there are some gems tucked away out of sight that can really go a long way to solving some of the most complex challenges.
One of those little Gems is the While Loop.
Here is a small example of not only the While Loop but also how to leverage it's power by using it in conjunction with a Non Persistent Business Object.
This example arose out a real world problem that we needed to solve.
Imagine this....
We have two Stacks. We have 20 (or any amount) of Tiles.
Initially, all 20 Tiles are on Stack 1
We need the following functionality.
- Click on a Tile and automatically move That Tile and all Tiles above it to Stack 2. In doing so, resequence the remaining Tiles in Stack 1 and esure the tiles in Stack 2 are sequence properly.
- Be able to automatically move the tiles that are now in Stack 2 back to their original place at the top of Stack 1 and resequence all the Tiles now back in Stack 1
- Alternatively, be able to automatically move the tiles that are now in Stack 2 back to Stack 1 but have them places at the bottom of Stack 1 but in the same order they were in while on Stack 2
Here is the Diagram

Here is a recording of the sample in action..... https://www.loom.com/share/9b4e562c44334d2c9d7a6e0a83c0ada8
Here is the sample BSV for you try....
The heart of the magic is located in the Non Persisted Business Object NP_StackTileRenumber. Have a look at the two BO Rules on that BO. One Rule is for ASC scans and one is for DESC scan. NOTICE HOW THEY ARE BOTH HAVE THE While Loop option Checked.
Depending on what parameters you CREATE this BO with.... It will immediately execute the appropriate BO Rule AND IT WILL CONTINUE TO EXECUTE IT WHILE THE CONDITION IS TRUE. And, here is the elegance of the solution.... Once it is finished, the instance of the BO disappears.
You can check out all of the Processes that are being called... Some to set up the parameters for the CREATE and some that are called by the NP BO.
We are finding places in our app where this has been extremely useful (5 instances now in a single app). Most of these tasks are just way to complex to solve using normal Aware IM Processes and without this While Loop functionality, we would have no option other than to build a Stored Procedure or a Plugin.
Happy to hear comments or questions.
Enjoy.