Skip to main content

Rule Editor

The operations for IF, SET and DO all use the same editor for building expressions. Expressions are built using the following components:

  • Data fields
  • Functions
  • Rule Parameters
  • Global Parameters
  • Temporary Parameters
  • Constants

Some notes on the above types:

ItemNotes
Data fieldsThese are the persistent attributes of your data (e.g. a time punch)
Rule ParametersThese are declared by the rule but don't have a known value (yet)
Global ParametersThis usually exist when an Initialization rule is present, which publishes its temporary variables for the rest of the rule to see
Temporary ParametersA temporary variable lives and is visible from the point of creation to the end of rule execution (that's why the temporary variables created in Initialization rules become Global); you create a temporary variable by simply using it as the left-hand side fo a SET function
ConstantsThese are generally on the right-hand side of a IF or embedded Function and are created as you use them

The Rules Editor is used to fill out the parameters for an expression. The search bar on the right side contains a collapsible tree of each of the above item categories (Data Fields, Functions, etc).:

Rule Editor SearchBar

Function Details

The tree is expanded by default, so scrolling down to the Functions category displays a list of all available functions. Clicking/tapping on a function displays the definition and parameters list:

Rule Editor

Searching for Items

At the top of the tree is a search box which allows you to easily find any item matching your search (in this case "date"):

Rule Editor Search

Filling In Parameters

There are two ways to enter values into the expression editor: dragging and dropping from the search bar, or clicking into the cell and simply typing. In this case, searching for "pun" in the search bar shows the matching Data Fields and Functions; next, drag PUNCH_ACTION over to the first parameter in the IF function to select.

Alternatively, click into the IF express and type "pun" to get the same list of matching items, then select PUNCH_ACTION from the menu.

When Functions are added to an expression, the generic version of the function is listed, which in this case is PUNCH_ACTION(column).

Rule Editor Add Function

Next we'll need to replace the parameter placeholder column with the desired value, in this case Description.

Rule Editor Add Function Parameter

The expression editor down one row with each parameter entry, and as functions can be come parameters to other functions, this nesting will often become three or four levels deep.

Choosing an Operator

After specifying the left-side of the expression, we'll move to the center to choose an operator. In this case we want the IF expression to return true/1 if the punch description is not an IN:

Rule Editor Add Function Operator

Then clicking into the right-side cell to enter a constant, IN.

Rule Editor Add Function Value

Lastly, press the Save button in the lower right to save the rule statement.

SET Equations

Further down in the rule we encounter the first SET. In this step, we want to calculate the elapsed time from the IN punch to the start of the schedule. As with the above IF equation, we start by filling in the left-side cell with our temporary variable minearly.

tip

To create a temporary variable, just enter its name in the left-side of any SET equation. To use the temporary variable, select it from the search bar or type its name into the right-side of an IF, SET or other function.

Rule Editor Set

In the above, we've dragged the TIME_DIFF_MINUTES function in to the right-side cell of the equation. A new row appears where we can provide the required inputs to the equation: two timestamps which will be compared and the difference in minutes returned.

For the first timestamp, search for Time in the search-bar and drag EffectiveTime to the left cell. For the second timestamp we enter SCHEDULE--a function which will return today's schedule. Another panel appears prompting for the input: in this case the field within SCHEDULE which we want to extract: StartTime.

Rule Editor Set Equation

The final expression for this rule statement is then:

SET(minearly = TIME_DIFF_MINUTES(EffectiveTime, SCHEDULE(StartTime)))

Final Statement

To close out this example, the final DO statement will use a function to set an exception on the IN punch.

For this step we use the SET_EXCEPTION function which applies an Exceptions Code from the Exceptions app to the underlying punch data. The SET_EXCEPTION function knows how to update the record and is used as a short-hand.

Rule Editor Final Set

Next, we'll look at how to apply rules and parameters to Pay Groups