Posted: 16 Jun 2016 1:42 EDT Last activity: 9 Nov 2016 19:02 EST
Query on LSA (7.1) Quiz - Business Rules - Declare-OnChange
Which of the following is not a good use case for using Rule-Declare-OnChange rules? (Choose One)
1. You wish to dynamically recalculate the sum of a list on the browser. (Correct Answer)
2. You wish to suspend work and call an audit flow when a risk score goes above a threshold.
3. You wish to execute an activity to call a collection whenever critical properties change in a temporary work object.
4. You wish to execute an activity to track changes to a pagelist each time that list is updated.
In the above quiz question, how to achieve option 4 using Declare-OnChange rule? I understand that we can refer a property present in a PageList property whose type is that of either the "Applies To" class of the Declare-OnChange rule or the class of the page referred in Page Context's class, but how does it ensure changes to PageList while it can track only the referred property in the PageList? Thanks in advance.
Why would dynamically recalculating the sum of a list on the browser not be a good use case for the Declare OnChange? Is the argument here that for a more simple task, a Declare Expression would be more appropriate (or am I missing something more fundamental)?
Posted: 4 years ago
Updated: 4 years ago
Posted: 9 Nov 2016 18:58 EST Updated: 9 Nov 2016 19:02 EST
The pattern that you are describing is using the Declare-OnChange to call an activity within which (I assume) you would perform the calculation in a property set step. This may not be as efficient as using a declare expression and raises the possibility that the property can be set by other means (by another activity or data transform for example) in which case the calculation you performed using the Declare-OnChange would no longer be valid. When you use a Declare Expression, a single Rule is used to perform the calculation and there are built in safeguards which prevent creating another rule which attempts to set the target property value if it is already set as the result of a Declare Expression. Additionally, the rule form for the Declare Expression expression presents a more clearer view of the calculation making it easier to understand and more maintainable.