Skip to main content

Introduction to Business Rules

While the Business Rules Admin Screen article covers the mechanics of viewing, editing, adding, cloning, deleting and deactivating rules via the Business Rules Admin screen, this article will give you an overview of how business rules work and cover best practices for creating efficient and effective business rules.

Overview

Within the Chrome River app, business rules are used extensively to implement policies and business controls that are tailored to your organization's needs. A wide variety of rules fire at different points in the application.

The Business Rules admin screen lets you create and manage your organization's custom Chrome River rules. Business rules are a reflection of your organization's business process: When your process changes, the rules need to be updated.

For Chrome River EXPENSE, some of the most common business rules are:

  • Compliance: These run when you save a line item and enforce policies for a specific line item.
  • Submit Compliance: These run when you submit an expense report for approval and enforce policies for an entire expense report.
  • Approval Routing: These are used to route expense reports across your organization for approval.

Chrome River's PREAPPROVAL, INVOICE and PURCHASE ORDER apps each have their own variants of these basic rules.

At this time, the Business Rules Admin screen supports the following rule types:

  • EXPENSE Line-Item Compliance
  • EXPENSE Submit Compliance
  • EXPENSE Approval Routing
  • PRE-APPROVAL Submit Compliance 

  • PRE-APPROVAL Routing

To create and manage other types of rules, you should continue to work with Chrome River's Configuration team via the Chrome River Help Desk.

Rule Example

Each business rule (independent of the rule type) has the same format:

IF
THEN

 

An example rule could be:

IF

LineItem ExpenseType = Airfare

AND

LineItem AmountSpent > $3000

THEN Show Warning (Message Code 205)

 

Business rules can contain multiple conditions, and each condition should evaluate to TRUE in order for the rule to fire.

Expense Line-Item Compliance Rule Parameters

EXPENSE Line-Item Compliance rules can access any of the following information for the IF (CONDITIONS) part of the rule:

  • Expense Owner: Any attribute of the Expense Owner, including Relationship Attributes that may be assigned to the user (e.g., Part Of / Office / New York)
  • Expense Report Header: Any attributes of the header, including any custom User Defined Attributes (UDAs) defined on the header
  • Expense Line Item: Any attribute of the current line item that is being saved, including custom User Defined Attributes (UDAs)
  • Allocation: Any attribute of the allocations linked to the line item

The following THEN (DO) actions are available for this rule type:

  • Show Warning Message
  • Show Warning with Response List
  • Show Violation Message
  • Set Cost Code Override

Operators and Wildcards

Business rules contain one or more conditions that must be met in order for the rule to fire. Rule conditions can be broken down into the following simple components:

<operand1><operator><operand 2>

<operand 1> encompasses the primary object and the attribute

  • Example: ExpenseOwnertitle equals “Project Manager”

In this example, ExpenseOwner is the primary object and title is one of its attributes.

<operator> is the function/logic applied to the operands

  • Example:ExpenseOwner title equals “Project Manager”

In this example, equals is the operator.

The list of available operators will depend on the values selected for <operand 1>. "ExpenseOwner title" is a text/String-based field, so the list of available operators will contain only those that apply to String fields (e.g., equals, not equals, begins with, ends with, contains).

By contrast, if <operand 1> was a number field like "LineItem amountSpent," the list of available operators would be specific to number fields (e.g., equals, not equals, less than, less than or equal to, greater than, greater than or equal to).

<operand 2> is the other value making up the condition

  • Example: ExpenseOwner title equals“Project Manager”

In this example, “Project Manager” is <operand 2>.

When a condition has an <operand 1> that is a String type (e.g., LineItem description, Allocation Number, ExpenseOwner title), you may use wildcards in <operand 2> via the matches operator.

A wildcard is a special character (.*) that can take any place of any number of characters, allowing you to search for any String value that begins before the wildcard.

  • Wildcard Example: ca.* would retrieve any string value that begins with "ca," including cat, cats, caterpillar, car, can, camera, cab, carousel, etc.

EXAMPLE

In this example, we have a Compliance rule with this logic:

IF

LineItem AmountSpent is greater than 50

AND

ExpenseOwner title equals “Staff Accountant Jr”

THEN Show Warning 203

Let’s say the rules need to be updated to also include ExpenseOwner with a title of "Staff Accountant Sr" or "Finance Manager." There are two ways you could write this rule, but one is more efficient than the other.

Option 1 (Not Recommended)

We could duplicate the existing rule two times and on the second rule change <operand 2> to be “Staff Accountant Sr" instead of “Staff Accountant Jr." On the third rule we would change <operand 2> to "Finance Manager.”

Technically this would work, but it is not the most efficient way to write the rules and will increase the number of rules unnecessarily.

Option 2 (Recommended)

Instead of having three separate rules, we can update the <operand 2> condition to reference a list of rules by using the matches operator. Entering a value in <operand 2> as a simple regular expression enables us to provide a list of values and also wildcards.

We can update the example rule as follows:

IF

LineItem AmountSpent is greater than 50

AND

ExpenseOwner title matches “Staff Accountant Jr|Staff Accountant Sr|Finance Manager”

THEN Show Warning 203

In the new version of the rule, <operand 2> now contains a list of values that are separated with a pipe character (|). We could also update the rule further and use wildcards:

IF

LineItem AmountSpent is greater than 50

AND

ExpenseOwner title matches “Staff Accountant.*| Finance Manager”

THEN Show Warning 203

In this version of the rule, a wildcard was added after "Staff Accountant" to expand the search. Now the condition would read as: "ExpenseOwner title begins with ‘Staff Accountant’ or equals ‘Finance Manager.'"

Operator Is In List / Is Not In List

When <operand 1> is a String field (e.g., LineItem Item Type), the list of operators will include:

  • Is in list
  • Is not in list

These operators are especially useful when the condition will reference the Item Type field. It is somewhat common for Compliance rules to only fire for specific Item types. Here’s an example rule:

IF

LineItem Item type matches “Breakfast|Lunch|Dinner”

AND

LineItem Tip Percentage is greater than 20

THEN Show Warning 204

This version of the rule uses the matches operator to refer to a list of expense types (Breakfast, Lunch, Dinner).

If you use the is in list operator, you will have the option to select from a list of defined expense types. That way you can easily add or remove items on the list without having to know the exact name of each expense type.

  • Note: The expense type's label name displays in the list. This may differ from the ex pense type's name in the database.

Complex Conditions

The Rule Editor will handle a number of complex conditions and present you with a series of options to select from to simplify the rule-creation process. Examples of such complex conditions include:

  • ExpenseOwner has role
  • LineItem is a duplicate

ExpenseOwner has role

Let's say you need to write a rule where the condition should only fire if the ExpenseOwner has a certain relationship attribute assigned. Relationship attributes assigned to your users are unique to your organization. Examples of relationship attributes would be:

    • Part Of / Office / New York
    • Part Of / Department / Finance
    • Part Of / Division / Widgets

For this example, you need to write a rule that only applies to ExpenseOwners based in the New York or Boston offices.

1. In the Rule Editor, you would create a condition with "ExpenseOwner has role."

2. Once the "has role" option has been selected in the Rule Editor, you will see a series of fields in the Toolbox on the right.

3. By selecting values from the Select Role, Select Entity Type, and Select Entity drop-down boxes, you will be able to generate your condition quickly and easily.

  • NOTE: The Entity selector allows multiple values, so you may select as many entities as you wish.

Line Item is a duplicate

This complex condition is used to determine whether the line item being saved is a duplicate of an existing line item, either on same report or on a different report for the same expense owner.

1. Create a condition starting with “ExpenseOwner” and click SELECT ATTRIBUTE to be presented with options in the Toolbox on the right hand side of the screen.

2. You may define a "duplicate" record in different ways. Maybe your definition of a duplicate line is a matching line item with same expense owner, same transaction date, same expense type. Or maybe your definition of a duplicate is a matching line item with same expense owner, same transaction date, same expense type, and same amount.

The Rule Editor will enable you to quickly select from a set of defined options by clicking the Strategy drop-down box.

Was this article helpful?