10.2.4.2. Defining constraints for employee rostering using the DRL designer
You can create constraint definitions for the employee rostering example using the free-form DRL designer in Business Central.
Use this procedure to create a hard constraint where no employee is assigned a shift that begins less than 10 hours after their previous shift ended.
Procedure
-
In Business Central, go to Menu
Design Projects and click the project name. -
Click Add Asset
DRL file. -
In the DRL file name field, type
ComplexScoreRules. -
Select the
employeerostering.employeerosteringpackage. - Click +Ok to create the DRL file.
In the Model tab of the DRL designer, define the
Employee10HourShiftSpacerule as a DRL file:package employeerostering.employeerostering; rule "Employee10HourShiftSpace" when $shiftAssignment : ShiftAssignment( $employee : employee != null, $shiftEndDateTime : shift.timeslot.endTime) ShiftAssignment( this != $shiftAssignment, $employee == employee, $shiftEndDateTime <= shift.timeslot.endTime, $shiftEndDateTime.until(shift.timeslot.startTime, java.time.temporal.ChronoUnit.HOURS) <10) then scoreHolder.addHardConstraintMatch(kcontext, -1); end- Click Save to save the DRL file.
For more information about creating DRL files, see Designing a decision service using DRL rules.