Views:

Scenario Overview

In this scenario we will demonstrate how to set up a Decision Table that calculates the yearly holiday entitlements for employees based on their age and length of service.

For this article it is assumed that you have at least basic familiarity with Decision Tables and/or have read the following articles:

Note: We will not detail step-by-step instructions here on how to set up Conditions or Actions, please read the above articles if you need detailed configuration steps.

The rules around holiday allotments are detailed below:

Rule 1
Every employee receives at least 22 holiday days a year.

Rule 2
Only employees younger than 18 or at least 60 years, or employees with at least 30 years of service will 
receive 5 extra days.

Rule 3
Employees with at least 30 years of service and also employees of age 60 or more, receive 3 extra days, on
top of possible additional days already given.

Rule 4
If an employee has at least 15 but less than 30 years, 2 extra days are given. These 2 days are also
provided for employees of age 45 or more. These 2 days cannot be combined with the extra 5 days.

In addition to the Birthday field, each Contact record has 4  additional custom fields added:

  • Start Date
  • Next Anniversary Date
  • Total Annual Holidays
  • Total Years 

Start Date is manually entered when the employee joins the company, but the other fields must be updated automatically by the Decision Table

N52 BPA Solution

The BPA solution works like this,

  • A formula of type Save - Perform Action is created on the Contact entity
  • The Source Properties are set to Birthday and Start Date  (custom field that needs to have been created beforehand)
    • Note : to select multiple Source Properties, hold down the ctrl key when selecting. 
  • The Event is set to Create & Update


Global Calculations Tab

Note: If the Global Calculations tab is not showing right-click on the Decision Table canvas and select Operations > Toggle Advanced Mode 

The Global Calculations Tab has 3 calculations used in the Decision Table

  • AgeCheck - used to calculate the current age of the Contact
  • YearsOfService - used to calculate the how many years the employee has worked for the company
  • AnniversaryCalc - used to calculate the next employment anniversary for the employee

Calculations 

Age Check
DateDiff([contact.birthdate], UtcDate(), 'y')

YearsOfService
DateDiff([contact.north52_startdate], UtcDate(), 'y')

AnniversaryCalc
if ( AddYears([contact.north52_startdate], DateDiff([contact.north52_startdate], UtcDate(), 'y') ) > UtcDate(),                                   

          AddYears([contact.north52_startdate], DateDiff([contact.north52_startdate], UtcDate(), 'y') ),

          AddYears([contact.north52_startdate], DateDiff([contact.north52_startdate], UtcDate(), 'y') +1 ) 
)


The Decision Table

In the screenshot below you can see that the Conditions have been added to the Decision Table.

The Global Calculation YearsOfService is being used both as a Condition and an Action here, as it an entitlement check for the Total Annual Holidays as well as being used to update the TotalYearsService field on the Contact record.
Note : After creating Global Calculations, you may need to refresh the Source tab via the refresh icon to the right of the search bar. 


This Decision Table will update the following fields when it executes

  • Total Annual Holidays
  • Total Years Service
  • Next Anniversary Date