DeclarativeProcessing 4
DeclarativeProcessing 4
Impact on Functions
Declarative expressions are rules that usually define formulas or calculations for a property. When using the Value of, it
allows us to enter calculations directly in the expression.
They also provide a number of out-of-the-box calculation types, such as Sum of, Average of, Count of and so on.
In addition, we call the utility function defined as part of the application which makes declare expressions extremely
powerful. When using functions unexpected behavior can arise causing issues especially when using forward chaining.
Forward chaining when used by expressions determines which properties the system should watch for changes. The list
of properties to watch is determined when the expression is saved by reading the rule data and looking for property
references. When the function dynamically refers to a property or the property is referenced indirectly as a string, as
opposed to a property reference unexpected behavior can arise. In other words if your property reference has quotes
around it there may be an issue.
Let’s look at some examples of how expressions can be written and the effect it has on change tracking.
Number Expression Change Tracked?
1 @Exp(.myValue) Yes
2 @getPropertyValue(".myProperty") No
3 @SizeOfPropertyList(.Borrowers) Yes
4 @countInPageList(true,".IsPrimaryBorrower",.Borrowers) No*
5 @indexOfMax(.Borrowers().FicoScore) Yes
1. The first expression uses the exponent function. Since the property is referenced normally forward chaining
occurs whenever myValue is changed.
2. The second example, calling the getPropertyValue function uses myProperty as a literal string and not a property
reference. In this case forward chaining does not occur, because the expression is not calculated when
myProperty changes.
3. The SizeOfPropertyList example uses a pagelist property named Borrowers and forward chaining occurs. Since it
is a page list, the execution computes when a new page is added or removed.
https://academy.pega.com/...ame=pyWorkPage&pzPrimaryPageName=pyWorkPage&pzTransactionId=3901c0197a345ada3e9f2fad51488bd9[4/29/2015 3:32:13 PM]
T abbed Navigation for Screen Flow T ake Lesson
4. The countInPageList example is an interesting one as it references two properties in different ways. The
borrowers page list is a property reference – notice there are no quotes. On the other hand IsPrimaryBorrower is a
literal string. In this example, the expression is calculated on creation or removal of a Borrower page however,
the expression is not calculated when the IsPrimaryBorrower property changes since it was referenced as a string.
5. The final example introduces a new syntax. In this example a ClibpoardPropertyCollection is passed to the
function. The system tracks both the page list and the single value property changes. The called function,
indexOfMax, is able to iterate over the collection of fico scores to find the index of the borrower with the highest
FICO score.
In the second example, we need to configure the declare expression since forward chaining expressions allow us to
define additional dependencies to track. This allows us to supplement the standard change tracking algorithm.
In some cases it may be difficult to pass all the property references and values in a way that works with forward
chaining so we may need to use backward chaining.