Best Practices - Propagation Rules
The propagate event is called by the supervisor on a property every time it has been successfully modified after the control. The best practices for using the propagate rule are the following:
* A propagate can be done on properties of the same class.
* A propagate can be done on properties of child classes even in a loop if several values have to been propagated.
* A propagate must not be done between properties of different lines of a collection.
The reason for this rule is simple: triggering updates between lines of the same collection can create loops of updates, especially if you consider that the order in which data is stored may differ from:
This makes such algorithms potentially unpredictable depending on the actions performed.
Another important point is that you must consider, when a propagation rule is done, that the order in which the fields are sent from the user interface may depend from the personalization done, and also from the communication mode.
Let's have an example:
The code that performs this is the following:
# This label is called from $PROPERTIES label in the script associated the class
$PROPAGATE_A
this.B="AA"
Return
Finally, A has the value "AA", and B the value "BB".
If the network bandwidth is not good enough, or if the representation is used on a mobile, or if the user types a value for B before entering a value for A, what may happen is the following:
Finally, A has the value "AA", and B the value "AA".
In order to avoid such an unpredictable result, it would be better to have this type of code:
# This label is called from $PROPERTIES label in the script associated the class
$PROPAGATE_A
If this.B<>""
this.B="AA"
Endif
Return
Of course, this kind of logic is an application choice: once as a value has been entered in B, the propagation rule will never apply.
If for any reason it would be interesting, in some cases, to reapply the "AA" value to the field B even if a value has been entered, the best solution would be to implement a SET_B_VALUE method in the class, and to call it from a dedicated link called "Init B" in the representation.