Dynamic Permutation

Dynamic Permutation


hi there,

I have a static entity, which has the values like below:

and then i want to get permutation for that n entities. The problem is that the number of entities is only known at runtime and some of the entities can have all the values (Match, UnMatch, Fuzzy) and some can only have two values (Match, UnMatch). For static number, say it 3 - 2 complete and 1 without fuzzy, i can create like this:

with the following 18 results:

My question is how to create logic that satisfies  n entities which are known at runtime? The n is known at runtime. I enclose with this, the oml.

Thank you in advance,



Hello Made,

I can't look at your code right now. But I would like to ask something.

What do you mean by "the number of entities is only known at runtime"?

In order to you to use an aggregate to fetch data from an entity, this entity must exist already in design time.

So, I'm a bit lost on what are you talking about here. Could you explain what do you mean?


Hi Eduardo,

Thank you for quick reply. I mean the number of entities is the number of GetMaching. In the example above there is only 3, but in my project there can be more or less than 3.. so it is dynamic. Other cases could be 4 getmatchings, say 1 getmatching with 3 match values above - match, unmatch, fuzzy - and the rest 3 getmachings are with 2 values - match and unmatch - so there will be 3x2x2x2 = 24 permutations. 

Thank you. Regards.


The number of Getmachings is only known at runtime and also the values fetch for each getmatching .. can be 3 or 2 (without fuzzy). 

Thank you in advance.

Best Regards,


Putu/Made (are you the same person?)

So, what is dynamic is the number of permutations, not the number of entities, as the number of entities (and the entities themselves) is known at design time.

Without knowing what exactly are those permutations you are doing, and the underlying entities structure it is hard for me to comment on how you can approach the problem.

"Dynamic" things like this, that require a different number of data fetching from database, are not an easy task to accomplish in any language in my opinion.

Said that...

Are the entities you are fetching data the same on each aggregate or are the entities different? If different, how do you decide which entity to fetch data?

Just to be clear, don't confuse an entity (table) with an aggregate, a statement that executes an SELECT and return a list of records.

If the entity is the same, only the filters in each aggregate are different, the problem possibly is easier to solve.


Hi Edu,

Yes, you are correct, the number of permutations, the static entity is only one only the filters are different.

How to? Thank you in advance.


Putu aka Made


Hi Putu/Made (are you one person?),

I cannot think the logic right now, but I believe to achieve this you must do a recursive function.

Please take a look at this:



I don't think the it MUST be recursive, but for sure it will be much easier (and "configurable" to enable different number of permutations) to use a server action...


Whether it is recursive or not (and every recursive can be done in a loop),  what is the algorithm to break this dynamic permutation problem in Ousystems?

Thank you in advance.

Best Regards.

It has been solved using recursion. I am thinking another way, of using advanced query. 

Thank you very much Paulo,