Replacement Chain
Dear Community,
Hope you can help me with this requirement;
1 In fact, we have a list of products and we want to replace it for example:
We have : A replaced by B then B replaced by C and C replaced by D what makes a chain of substitution ABCD. What I want to display on each line is the first product of the chain in our case "A"
N.B :
 New Product : enterable by User
 First Product of the chain : calculated by formula and displayed
 Warning : calculated by formula and displayed
2 I want to display error message on this specific case (we cannot replace the same product twice, for example we cannot have A replaced by B and G replaced by A.).
Thank you for your help
Comments

@TAGORTII just stuck with your warning message. Do i understand correctly that the order of the list members matters in calculation? I can see in your example that error message is only against "I" because NEW PRODUCT mentionned there is "G". And "G" stays prior to "I". I am asking because if we ignore the error, then the chain will look like this: IGJ, which can be calculated as FIRST PRODUCT OF THE CHAIN = "I".
Or this means that error appears only if any product mentionned more that once?
If this is actually the case then you have to concider the above in your calculation.
0 
Hello @KirillKuznetsov ,
Thank you for your reply.
In fact the order doesn't matter, the error must appear when an old product (already substituted) is used as a new product for another product.
Regards,0 
In this case B and C also follow this rule and must be NOK. At least this is what I see on your screenshot. Could you comment on that?
0 
In the first case is as follows : ABCD so no error.
In the second case : EF and GE so the chain will be GEF this is an error on the second line.0 
I don't see any difference, but the order in which the new products are assigned and only in case if the order of the products matches with the order of new products being assigned0

Another question. Do these new products have to appear only once in the line item?0

The order of the new product assignment and the occurrence of the new products differs from the first case.
If I already substituted a product i cannot used as a new product.
Did you find a solution for the first part of the requirement ?Thanks
0 
yes one time
0 
Do you know the maximum length of such chain?0

@KirillKuznetsov I think the maximum should be at 4050
0