[<10>] ====== Cross-reference Rules ====== Cross-reference rules are rules that refer to a particular instance of a business object through the [[docs:2000_concepts:0200_basics:0400_reference_attributes|reference attribute]] of another object. For example, let us assume that our ''Policy'' business object has a reference attribute declared – this reference is to the ''Driver'' for which the policy is made. Let us assume that the name of this attribute is ''MyDriver''. Our age rule should now be written like this: IF Policy.MyDriver.Age > 70 THEN INCREASE Policy.Excess BY 100 We should also make modifications to the process that enters the details of the driver and calculates the policy to initialize the ''MyDriver'' attribute of the ''Policy'' object appropriately: ENTER NEW Driver CREATE Policy WITH Policy.MyDriver=Driver The age rule written in the above form refers to the instance of the ''Driver'' object through the reference of the ''Policy'' object (''Policy.MyDriver.Age''). This rule therefore is a cross-reference rule. Cross-reference rules are evaluated whenever the instance of the object they refer to is changed. Consider what happens if a policy for some driver has been calculated but then the user realizes that she had made a mistake and entered the wrong age of the driver. She brings up a form for the driver and changes the value of the ''Age'' attribute. Let us see what happens when the changes are submitted. The particular instance of a ''Driver'' object is modified and therefore if there are any rules attached to the ''Driver'' object they are evaluated. Let us assume for simplicity that there are no such rules. There is however a rule that refers to the ''Driver'' object – this is our age rule. //**Aware IM**// automatically finds the instance of the ''Policy'' object that refers to the instance of the modified ''Driver'' object and starts evaluating the cross-reference rule. Thus the system guarantees that the excess is correctly calculated no matter where the change that affects its calculation happens! If the age value entered first was 70 and the correct age is 71 then the excess will be re-calculated as soon as the correct age of 71 is submitted. Note that //**Aware IM**// will re-calculate cross-reference rules only for those instances of business objects that refer to the modified instances – in our example, only the ''Policy'' instance that refers to the modified ''Driver'' object will be re-calculated; all other policies will not be considered. There is a flag in the Configuration Tool that allows you to explicitly turn off the cross-reference rule mechanism for a particular rule (see[[docs:2500_config_apps:0800_add_edit_rules:0400_rule_properties| Advanced Rule Options]]). When this flag is turned off for a rule the rule is never recognized as a cross-reference rule, so if any attributes referred to by this rule are modified the rule is not evaluated. Turning off this flag may be useful if evaluation of a cross-reference rule as a result of an attribute change leads to modification of a large number of business object instances. For example, let us say that our ''Policy'' object refers to a ''StampDuty'' object in a rule that calculates commission of the policy: Policy.Commission = Policy.Value/20 + Policy.StampDuty.Rate/100 If rate of the ''StampDuty'' object changes this change will cause re-calculation of all policies in the system through the above rule, which is normally interpreted as a cross-reference rule. If there are a large number of policies in the system their re-calculation may take up significant time. You may want to warn the user about the effect of such change or even defer the execution of the change until nighttime. In this case you would like to configure a process that would control the changes to critical attributes of the system and turn off automatic recognition of cross-reference rules.