Expressions
An “Expression” gives a rule administrator the ability to add additional conditions to limit a rule’s invocation that may not otherwise be available by increasing specificity of a matching line in a rule table.
Expressions are a type of programming language construct using one or more functions, variables and/or constants joined by operators. An expression is evaluated and produces a result and, depending on the results, will determine if the rule should be invoked or not. WorkSight FLOW’s expression builder is very comprehensive, including a wide range of variables, functions, and operators.
There are 4 columns in the rule tables that accept expressions;
- 'Expression' Column
- 'Day of Week' Column
- 'Apply To' Column
- 'Observed On' Column
Working with Expressions
In a Rules table, to display expressions: double click on the cell you wish to add the expression to. This opens the Expression Editor. Press CTRL+Spacebar to reveal the list available:
A wrench icon in the list indicates a database field, a block icon indicates an expression.
Choose an expression from the list. If you hover over the expression, a tool tip pop-up shows how it should be completed.
As you complete the expression, any errors are underlined with a red line. In the example shown below, the asterisk displayed before the expression should be deleted. When the expression is complete, the OK button activates.
An incomplete expression:
An expression with an error:
An example of a completed expression, with values and operator(s):
Click OK in the Expression Editor and save the Rule.
Available Expressions by Column:
'Expression' Column
Available in: Minimum Amount Rules, Overtime Rules, Premium Rules, Scale Rates, Rate Rules, Account Code Rules.
EXPRESSION | DEFINITION | EXAMPLE OF USE |
---|---|---|
isHoliday() | Returns true if the day that is being evaluated matches any row on the Holiday Table | isHoliday() Rules containing this expression will only apply if the timecard conditions match any row in the Holiday Definitions table |
isScheduledDayOff() | Returns true if the assigned shift pattern does not have a shift scheduled on the day that is being evaluated | isScheduledDayOff() Rules containing this expression will only apply if the timecard being evaluated is the employee's regularly scheduled day off (based on the employee's assigned shift pattern) |
isXHoliday(effective) | Returns true if the day that is being evaluated matches the specified holiday on the Holiday Table | isXHoliday('Christmas Day') Rules containing this expression will only apply if the timecard conditions match a row in the Holiday Definitions table with 'Christmas Day' specified in the Holiday column |
isXScheduledDayOff(dayOffset) | Returns true if the day that is being evaluated matches the offset specified in the expression | isXScheduledDayOff(2) Rules containing this expression will only apply if the day being evaluated is the employee's 2nd scheduled day off within the payroll week (based on the employee's assigned shift pattern) |
consecutiveDays() | Returns a numerical value representing the number of consecutive days that the employee has worked using the Hours Earned type specified in the row | consecutiveDays() == 3 Rules containing this expression will only apply if the employee has worked 3 consecutive days |
daysWorkedInLastXDays(n) | Returns a numerical value representing the number of days that the employee has worked during the previous specified number of days (n) | daysWorkedInLastXDays(4) == 1 Rules containing this expression will only apply if the employee has worked 1 out of the last 4 days |
daysWorkedOnScheduledDaysOff() | Returns a numerical value representing the number of scheduled days off that the employee reported worked hours for | daysWorkedOnScheduledDaysOff() == 3 Rules containing this expression will only apply if the employee worked 3 of their scheduled days off within the payroll week |
daysSince(effective) | Returns a numerical value representing the number of days since either "Seniority Date" or "Hire Day", as specified |
daysSince(SeniorityDate) > 100 Rules containing this expression will only apply if the employee's seniority date is more than 100 days in the past |
intersects(start,end) |
Returns true if any of the hours an employee works intersect the start and end times specified |
intersects(18,31) Rules containing the expression will only apply if the employee's shift has any time scheduled between 6 pm and 7 am the following day |
rateFactor() | Returns a numerical value representing the rate factor using the Hours Earned type specified in the corresponding rule row |
rateFactor() == 2 |
hireDate() | Returns the date value in the built-in UDF field 'Hire Date' |
hireDate() < 2020-11-25 Rules containing this expression will only apply if the employee's Hire Date is earlier than 2020-11-25 |
scheduledToShiftOn(shiftType, dayofWeek) | Returns true if the employee worked the specified shift on the day specified within the payroll week |
scheduledToShiftOn('D', 'Tuesday') Rules containing this expression will only apply if the employee worked a D shift on Tuesday |
seniorityDate() |
Returns the date value in the built-in udf field 'Seniority Date' |
seniorityDate() < 2020-11-25 Rules containing this expression will only apply if the employee Seniority Date is earlier than 2020-11-25 |
hoursWorked() |
Returns a numerical value representing hours earned in the current day using the Hours Earned type specified in the corresponding rule row |
hoursWorked() > 8 Rules containing this expression will only apply if the hours worked is greater than 8 |
hoursWorkedInWeek() |
Returns a numerical value representing hours earned in the current pay week using the Hours Earned type specified in the corresponding rule row |
hoursWorkedInWeek() > 40 Rules containing this expression will only apply if the hours worked in the pay week is greater than 40
|
hoursWorkedDuring(start,end) |
Computes the number of hours worked between start and end times. |
hoursWorkedDuring(23.5,30.5) > 0.5 Rules containing this expression expression will only apply if the sum of the hours between the specified times is greater than 0.5 |
dataType.udf() |
Returns true if the Data Type UDF that is being evaluated matches what is specified in the expression |
shiftType.udf("Shift Category") == '06:00'
Rules containing this expression will only apply if the Shift Type UDF called Shift Category is equal to 06:00
|
'Day of Week' Column
Available in: Holiday Definitions, Minimum Amount Rules, Overtime Rules, Premium Rules, Scale Rates, Rate Rules
EXPRESSION | DEFINITION | EXAMPLE OF USE |
isDayOfWeek(dayOfWeek) | Returns true if the day that is being evaluated matches the day specified in the expression (i.e. isDayOfWeek(Thursday)) |
isDayOfWeek('Thursday') |
isMonday() | Returns true if the day that is being evaluated is Monday | isMonday() Rules containing this Day of Week expression will only apply on Mondays |
isSunday() | Returns true if the day that is being evaluated is Sunday | isSunday() Rules containing this Day of Week expression will only apply on Sundays |
'Apply To' Column
Available in: Premium Rules
EXPRESSION | DEFINITION | EXAMPLE OF USE |
hourForHour() | Applies the premium for the same amount of hours as there are regular worked hours |
hourForHour() |
minUpToMax(min,max) | Sets a minimum and a maximum amount of hours for the premium to apply for | minUpToMax(2,6) This will apply the premium for an amount of min 2 units up to max 6 units |
hoursBetween(start,end) | Applies the premium for the hours between a specified time range | hoursBetween(10,15) This will apply the premium to hours worked between 10:00 am and 3:00 pm |
amount | Numerical value | 8 This will apply the premium for 8 hours |
hourForHourAsRatio() | Applies the premium as a ratio of hours worked. The ratio amount will be defined in the '1st factor' column of the corresponding row |
hourForHourAsRatio() - used with 1st factor of 0.1429 This will apply 0.1429 units of the premium for every 1 hour that the employee worked |
'Observed On' Column
Available in: Holiday Definitions
EXPRESSION | DEFINITION | EXAMPLE OF USE |
sameDayAsHoliday() | Observe the holiday on the actual date |
sameDayAsHoliday() |
nearest(dayOfWeek) | Observe the holiday on the specified day of the week that is closest to the actual holiday | nearest('Friday') Rules referencing holidays with this 'Observed On' expression will apply on the Friday that is closest to the actual holiday date |
following(dayOfWeek) | Observe the holiday on the specified day of the week that occurs after the actual holiday day | following('Friday') Rules referencing holidays with this 'Observed On' expression will apply on the Friday occurs after the actual holiday date |
preceding(dayOfWeek) | Observe the holiday on the specified day of the week that occurs before the actual holiday day | preceding('Friday') Rules referencing holidays with this 'Observed On' expression will apply on the Friday occurs prior to the actual holiday date |
nearestWhen(nearest,when) | Observe the holiday on the specified nearest day of week when the holiday falls on the specified day(s) of the week |
nearestWhen('Friday', ['Thursday', 'Friday', 'Saturday']) Rules referencing holidays with this 'Observed On' expression will apply on the nearest Friday when the holiday falls on Thursday, Friday, or Saturday |
Operators
An operator is a word or symbol that indicates a specific arithmetic or logical relationship between the other elements of an expression (i.e. Comparison: <, >, =; Logical: &&, ||, !).
Comparison Operators
Comparison operators will compare two values and return a True or False.
Comparison operators include:
EXPRESSION | DEFINITION | EXAMPLE OF USE |
---|---|---|
> | Greater Than | daysWorkedInLastXDays(5) > 3 Employee has worked GREATER THAN 3 out of the last 5 days |
< | Less Than | daysWorkedInLastXDays(5) < 3 Employee has worked LESS THAN 3 out of the last 5 days |
>= | Greater Than or Equal To | daysWorkedOnScheduledDaysOff() >= 3 Employee has worked GREATER THAN OR EQUAL TO 3 of their scheduled days off |
<= | Less Than or Equal To | daysWorkedOnScheduledDaysOff() <= 3 Employee has worked LESS THAN OR EQUAL TO 3 of their scheduled days off |
== | Equal To | daysWorkedOnScheduledDaysOff()==2 Employee has worked EQUAL TO 2 of their scheduled days off |
!= | Not Equal To | daysWorkedOnScheduledDaysOff()!=2 Employee has NOT worked EQUAL TO 2 of their scheduled days off |
Logical Operators
Logical operators combine multiple expressions or values and provide a single output.
Logical operators include:
EXPRESSION | DEFINITION | EXAMPLE OF USE |
---|---|---|
&& | AND | isScheduledDayOff() && (daysWorkedOnScheduledDaysOff()=2) True if the day of week being evaluated is a Scheduled Day Off AND the employee has worked equal to 2 of their days off (Both of the statements must be true for the rule to apply) |
|| | OR | isDayOfWeek('Saturday') || isSunday() True if the day of week being evaluated is Saturday OR Sunday (Either one of the statements can be true for the rule to apply) |
! | NOT | !isSunday() True if the day of week being evaluated is NOT a Sunday |
Comments
0 comments
Article is closed for comments.