Table of Contents

How to qualify Declare-Expression, Declare-Constraints, and Declare OnChange rules

Summary

You can use time-qualified and circumstance-qualified rule resolution features with Declare OnChange, Declare Expression,and Declare Constraints rules.

The tools and utilities associated with declarative rules such as the Declarative Network display, Rules Inspector, Tracer, and System Management Application are not limited or affected by the use of declarative rule qualifications.

This article describes how you use qualified rules of these types..

 

Suggested Approach

As with all circumstance-qualified rules, the base and circumstanced instances of declarative rules must have the same keys. Because declarative rules can be executed at any time as a result of property references and changes, declarative rules run within their own page context during evaluation and not within the context of a Primary page. Therefore, a circumstance property reference in a declarative rule is evaluated relative to the rule's page context and not the current Primary page

For Constraints and OnChange rules, the key parts are Applies To class and Purpose. The Page Context references on the base rule and each circumstance-qualified rules must be identical..

For Declare Expression rules, the keys are Applies To class and Target Property. Page Context is also used as a key when using a Page List or Page Group property. The base and circumstance-qualified instances of a Declare Expression must have matching change-tracking and context execution strategies; that is, the base instance and its circumstance-qualified instances must all be forward chaining or all backward chaining, and must be all context-bound or all context-free.

 

Examples

The following examples illustrate how context-free and context-bound Declare Expression rules work when using circumstance-qualified expressions.

  • A context-free expression— the circumstance properties refer to the class of the Applies To class of the expression rule (since there is no Page Context defined on the rule). Using context-free expressions, when appropriate, can reduce the number of Declare Expression rules you must build and maintain in your application.

    Example: The Applies To class is Data-Item, the expression is ".Tax = Cost * .05", and the circumstance is ".State = MA". The input, output, and circumstance properties are all defined on Data-Item. When the application runs, the page context is an instance of Data-Item, which can be a top-level page or embedded in any page structure.
    For instance, setting MyDataObject.ADataItem.Cost, the expression uses MyDataObject.ADataItem as the page context and the relevant circumstance property is MyDataObject.ADataItem.State. Setting MyDataItem.Cost, the expression uses MyDataItem as the page context and the relevant circumstance property is MyDataItem.State.

  • A context-bound expression with a page context key —the circumstance properties refer to the class of the Context Class of the expression rule and not the Applies To class.

    Example: The Applies To class is Data-Transaction, the page context is .Item() and the page context class is Data-Item. The expression is ".Tax = .Cost * .05" and the circumstance is ".State = MA". The input, output, and circumstance properties are all defined on Data-Item. When the application runs, the page context is an instance of .Item() embedded on a top-level page of class Data-Transaction. For instance, setting MyDataTransaction.item(2).Cost, the expression uses MyDataTransaction.item(2) as the page context. The relevant circumstance property is MyData Transaction.item(2).State.

 

How circumstance-qualified declare rules are re-evaluated

The following describe circumstance-qualified declare rule behavior during re-evaluation:

  • Declare Expression rules that use the "calculate value whenever inputs change" option, and all Declare Constraints and Declare OnChange rules. use forward chaining to keep their output properties current.
  • In most cases, a declare rule's circumstance properties and input properties are re-evaluated in similar fashion. When a circumstance property's value changes, the declarative network re-evaluates the expression or constraint. However, if a circumstance property reference uses a top-level page name, changing that property's value does not cause the declarative network to re-evaluate the expression or constraint.
  • Circumstance resolution occurs when the rule is being evaluated and not when an input property changes. For example, assume a Property-Set step changes an expression input and the circumstance property (in that order). During forward chaining, the expression uses the new circumstance value even though the input property was changed when the circumstance property had a different value.
  • Declare Expression rules invoked by GoalSeek or with any other "calculate value" options use backward chaining. In this case, the expression is calculated only on demand. Therefore, changes to input properties and circumstance values do not cause the expression to be re-evaluated automatically. The circumstance is checked only when the expression is invoked.
  • Time-qualified circumstance are only checked during expression evaluation. The passage of time alone does not cause re-evaluation of declarative rules.
Suggest Edit

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.