Using Macros inside OpenRules Expressions

A new OpenRules Release 6.3.0 introduced “macro” to simplify an access to  decision variables. For example, you may write a formula like below

DefineResultNew

Here macros ${Greeting} and ${Salutation} will be replaced to the actual values of the proper decision variables to assign to the variable “Result” something like “Good Afternoon, Mrs. Robinson!”.

Macros ${variable name} are used to get the current value of the proper decision variables of the type String.  For other types of variables you need to add one more letter between ‘$’ and ‘{‘ as described in the following table:

Macros

For example, in the formula

CalculateTotalPaymentsNew

macro $R{…} are used for real variables and $I{Extra} for the integer variable “Extra”. If a user uses an invalid type, the proper warning will be produced.

The reason we force a used to specify a variable type is justified by the fact that OpenRules will recognize the actual types of variables only during a decision’s run (and not when it is created). For example, if you use a decision variable “Amount” inside expressions like “Amount < 1000“, OpenRules only requires that the type of the variable”Amount” supports the comparison operator “<” but the actual type could be either integer or real. Moe than that, you may even change the variable types between different runs of the same decision.

There is an alternative (even simpler) way to refer to a decision variable of the type String when it represents the entire content of an Excel cell. For example, instead of the formula

    ::= ${Selected Airline}

you may simply write

    $Selected Airline

Similarly, for a list of strings  you may put in your decision table cell something like this:

    United, $Selected Airline, Delta

and $Selected Airline will be replaced by its actual value.

Read more about the OpenRules expression language at the User Manual on the page 19. As macros can be freely used inside Java snippets, we expect that they will make OpenRules expressions much more friendlier for business users.

Advertisements

About jacobfeldman

CTO at www.openrules.com http://www.linkedin.com/in/jacobfeldmanopenrules
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s