Consolidate Multiple Default Configurations
Apply dynamic, overridable default quantities to a single component based on multiple states of a driving attribute, using one derived variable and a single setdefault rule.
Apply dynamic, overridable default quantities to a single component based on multiple possible states of a driving attribute. This process avoids rule conflicts where only the last rule evaluates.
When multiple setdefault rules target the same assignment in the RHS, evaluations can conflict. For example, a conflict can result when the rule targets the same relation and type, such as accessories[Accessory] == .... The condition side can use different expressions, but if the rules resolve to the same target on the assignment side, behavior can become order-dependent and lead to inconsistent outcomes.
For example, if you want to set a default for the quantity of Accessories based on the selected DutyRating of a Generator Set, writing three separate setdefault rules causes inconsistent behavior depending on the quantity changes of the accessories.
To prevent the conflict, consolidate the conditional logic into a single derived variable using nested ternary expressions, such as ? :. Then, apply a single setdefault rule using that newly derived variable to drive the relation’s quantity.
This example shows the recommended process, consolidating the logic into a single variable and rule.
Avoid the process shown in this example, which includes multiple conflicting setdefault rules.