How do you model labor laws, union rules and mandatory technician breaks in Salesforce Field Service scheduling?
Answer
Field Service has no single "labour law" switch. Compliance is built from several settings that you combine, and then checked with reports.
Building blocks
- Operating Hours and Time Slots: cap the hours a technician can be scheduled each day and week.
- Resource Absences of type Break: reserve a mandatory break, such as a 45-minute lunch, so the engine never schedules over it.
- Service Resource Availability work rule: makes the engine respect those hours and breaks.
- Minimize Overtime objective: steers work away from overtime hours where possible.
- Time Sheets and Time Sheet Entries: record actual hours for payroll and audit.
- Union or contract rules (for example job types only certain staff may do): use skills, Extended Match or Excluded Resources.
Create daily breaks in Apex
apex
List<ResourceAbsence> breaks = new List<ResourceAbsence>();
Date tomorrow = Date.today().addDays(1);
for (ServiceResource sr : [SELECT Id FROM ServiceResource
WHERE IsActive = true AND ResourceType = 'T']) {
Datetime start = Datetime.newInstance(tomorrow, Time.newInstance(12, 0, 0, 0));
breaks.add(new ResourceAbsence(
ResourceId = sr.Id, Type = 'Break',
Start = start, End = start.addMinutes(45)
));
}
insert breaks;