All throughout LMS, you can use Clojure Rules to automate parts of your workflows, like rules applied and flags. But even once you've got the hang of Clojure, it can be time consuming to write out the same rule in several different places. The Rules Manager solves this problem—you can save a list of rules, and then pull from that list any time you're writing one.
The Rule Manager
In LMS, the rules manager is located in Settings > Company > Rules Manager.
You'll see a list of the existing rules saved in your system. These will be available anytime you're asked to write a rule. Each entry includes the name, the text of the rule itself, whether and how the answer is rounded, and the type of output it yields.
Adding New Rules
To create a new rule, the blue 'Add' button in the top right corner. That'll bring up this window with fields for basic info, and one large field where you can enter your Clojure rule.
The top section is where you can enter basic information about the rule. You have the following options:
This text field lets you add a name for each rule, distinguishing them from any others you add.
The rule won’t necessarily output a value, but if it does, this field lets you choose what type of value it will output: number, date, or currency.
If the rule outputs a numerical value, you can choose to round the answer, from a whole number or up to six decimal places.
Here you can select either True/False Output or Value Output. This specifies whether the rule valuates to a specific value or to just a true or false answer.
On the lower half of the screen, you'll see the formula editor. This field is where you'll actually enter a Clojure rule.
There is only one field in this section, but this is the field where the actual rule will be entered. You can manually enter the rule, load and edit an existing rule, add system variables, or use the shortcut buttons below the field. These buttons include: +, -, *, / operators, a logical AND and OR, parentheses, and equality operators and values. Some of the equality operators and values may not be familiar.
This compares two values to see if they are equal.
This means 'not equal'.
This means 'true'.
This means no value. This is different than 0, which is a numerical value. (You can perform math operations with 0; not so with NIL.)
When you've finished writing a rule, be sure to click 'Validate this Rule'. This will check if your Clojure rule is valid, or if it produces any errors.
Note the blue 'Load Existing Rule' button. This lets you load a rule that's already saved in your Rule Manager, and it's how you'll actually use the rules you save in other parts of the software. Whenever the system asks you to create a rule, that button will pull up a list of the rules you've already saved. Here, you can use it to build new rules from existing ones. If you choose to load an existing rule, you should note the message “If your rule includes the characters ‘%1’, it is intended as a placeholder. You should replace these characters with a numeric value (either static or dynamic).”
The bottom section lets you search through and select system variables.
On the left all the variables are arranged in a tree structure. Click the plus on the left of any section to expand it. Clicking the bullseye to the left of an individual variable variable will pull up its data. Use the 'Search by keyword' field to filter the list of variables by a keyword or key phrase.
In the Info pane on the right, you can view the information about any variable. If you click they hyperlinks in this pane, the variable will be inserted into your formula. Our article Using Variables in Computation Rules gives a little more info on how they're used.