Wish: nested conditionals

Contains tips for configurators working with Aware IM
Post Reply
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

Wish: nested conditionals

Post by tkilshaw »

This may subvert how the rule engine works but I would like nested conditional expressions. For example

IF A then
IF B then
... do stuff
ELSE
.. do stuff
END IF
.. do stuff
END IF

Terry
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

Terry,

You are right, nested conditional expressions are not supported because they go against the rule engine implementation for reasons described in details in Configuration Principles under the Configuration Guidelines section of the Aware IM User Guide. Generally, Aware IM encourages a non-procedural approach to specifying business logic. Consider an example form the Library application where a member should be notified by email or letter when a reserved item becomes available. In a scripting language this could be expressed like this:

Code: Select all

If Reservation.Status WAS CHANGED TO 'Offered'
  Then If Reservation.Member.EmailAddress IS DEFINED
    Then SEND ReservaitonOfferEmail TO Reservation.Member
    Else PRINT DOCUMENT ReservaitonLetter
In Aware IM the same logic is expressed by the following two rules:

Rule 'Reservation offer e-mail':

Code: Select all

If Reservation.Status WAS CHANGED TO 'Offered'
  AND Reservation.Member.EmailAddress IS DEFINED
Then SEND ReservaitonOfferEmail TO Reservation.Member
Rule ' Reservation offer letter ':

Code: Select all

If Reservation.Status WAS CHANGED TO 'Offered'
  AND Reservation.Member.EmailAddress IS UNDEFINED
Then PRINT DOCUMENT ReservaitonLetter
Note that both rules have clearly-defined semantics and both are visible in the rule table for the object. This makes it easier to comprehend the business logic without having to open each rule and study the details.

Here are a few related points worth considering in this context:

a) By default, the order of rule execution is undefined. If certain actions must follow a particular order, such actions should be specified within a single rule (with or without conditions). If is also possible to change rule execution priority in the Advanced section of the rule dialog.

b) The system automatically tracks dependencies between rules (including cross-object dependencies) and executes rule actions again if dependent data is changed. For example, Rule 2 below will be executed again if the execution of Rule 1 changes the attribute value:

Code: Select all

Rule 1:  If ... Then MyObject.Attribute1 = ...
Rule 2:  MyObject.Attribute2 = MyObject.Attribute1 + MyObject.Attribute3
c) With complex logic, where rules may have a number of conditions with many of them repeating across several rules, consider introducing attributes indicating the object state. For example, the Reservation object in the Library application can be in one of several states. There is a different set of rules that applies to each state. Each of such rules will start by checking the object state to see if it applies.

Some rules will be responsible for making decisions to move the object into a different state if the conditions are right. The state-based approach allows breaking up complex procedures into a number of more manageable steps. Quite often such states already exist in the business domain so they can be re-used in the application design.
Aware IM Support Team
Post Reply