Shift site-local times

Shift site-local times

Why these fields exist

Shift start and end times (b3s__Scheduled_Start_Time__c, b3s__Scheduled_End_Time__c, b3s__Actual_Start_Time__c, b3s__Actual_End_Time__c) are Date/Time fields. They store one exact moment in time. WFM apps display those moments according to their configured app timezone. Native Salesforce views use the viewing user's timezone.

Standard Salesforce screens show Date/Time fields in the timezone of the person viewing them. This applies to record pages, list views, reports and email templates. A 10:00 shift at a Madrid site shows as 09:00 to a user in the UK and as 04:00 to a user in New York. An email template sent by a UK user tells the worker the shift starts at 09:00.

The site-local fields fix this. Each one holds the site's calendar date or wall-clock time as a Date or Time value. Salesforce never shifts Date and Time fields by timezone, so the value is the same for every user, in every report and in every email.

Fields on Shift

All fields are read-only and set automatically. Do not edit them, because any change is overwritten the next time the shift is saved.

Field label API name Type Source
Site Scheduled Start Date b3s__Site_Scheduled_Start_Date__c Date Scheduled Start Time
Site Scheduled Start Time b3s__Site_Scheduled_Start_Time__c Time Scheduled Start Time
Site Scheduled End Date b3s__Site_Scheduled_End_Date__c Date Scheduled End Time
Site Scheduled End Time b3s__Site_Scheduled_End_Time__c Time Scheduled End Time
Site Actual Start Date b3s__Site_Actual_Start_Date__c Date Actual Start Time
Site Actual Start Time b3s__Site_Actual_Start_Time__c Time Actual Start Time
Site Actual End Date b3s__Site_Actual_End_Date__c Date Actual End Time
Site Actual End Time b3s__Site_Actual_End_Time__c Time Actual End Time
Site Timezone b3s__Site_Timezone__c Text(40) The timezone used, for example Europe/Madrid
Site Weekday b3s__Site_Weekday__c Formula (Text) Weekday of Site Scheduled Start Date, Monday to Sunday
Overnight b3s__Is_Overnight__c Formula (Checkbox) Checked when the scheduled shift crosses midnight at the site

Site Weekday and Overnight always follow the scheduled times, not the actual ones, so a worker clocking in a few minutes early never moves the shift to another day. Site Weekday is always in English. A shift that ends at exactly 00:00 is not overnight, because no time is worked after midnight. A shift running past midnight, or longer than a day, is overnight.

Each time has its own date because overnight shifts end on a different date from the one they start on. When a source time is blank, for example before the worker clocks in, the matching site-local fields are blank too.

The fields are in the Site Local Times section of the Shift page layout. The WFM Admin permission set grants read access. If you use another permission set or profile, grant read access to these fields there as well.

How the timezone is chosen

  1. The Timezone (b3s__Timezone__c) of the shift's Work Site.
  2. If the shift has no site, or the site has no timezone, the org default timezone is used (Setup, Company Information).

The timezone of the user saving the shift is never used. If it were, the stamped value would depend on who last saved the record.

Daylight saving time is handled automatically. The offset is worked out separately for each time, so a shift that crosses a daylight saving change is stamped correctly.

When the fields are updated

Upgrading from 10.7.0: the automatic backfill condition does not run. Use the manual backfill for existing shifts whose site-local fields are blank.

Manual backfill

To re-stamp shifts that have no values yet, download backfill-shift-site-times.apex from the Version 11 release downloads and run it as anonymous Apex. It processes up to 3000 shifts per run. Run it again until Remaining prints 0.

Integer capacity = 3000;

List<b3s__Shift__c> shifts = [SELECT Id FROM b3s__Shift__c WHERE b3s__Site_Timezone__c = null LIMIT :capacity];
update shifts;

System.debug('Stamped ' + shifts.size() + ' Shifts');
System.debug('Remaining: ' + [SELECT COUNT() FROM b3s__Shift__c WHERE b3s__Site_Timezone__c = null]);

Re-saving a shift with no other changes does not regenerate breaks, recount demands or clear event alerts. Those processes only react to changes in the fields they watch.

Using the fields

Reports

Use the site-local fields wherever a report should show what the worker sees on site:

Keep using the original Date/Time fields for duration calculations and anything that compares exact moments across sites.

Email templates

Use the date and time pair in place of the Date/Time field, for example in a Lightning email template:

Your shift on {{{b3s__Shift__c.b3s__Site_Scheduled_Start_Date__c}}} starts at
{{{b3s__Shift__c.b3s__Site_Scheduled_Start_Time__c}}} ({{{b3s__Shift__c.b3s__Site_Timezone__c}}}).

Each recipient sees the site's local time whatever the sender's timezone. Salesforce formats the date and time using its locale settings; only the timezone shift goes away.

Pay rules and filters

Use Overnight to find night shifts or apply night premiums in Flows and reports. Use Site Weekday to group by day of the week or filter weekend shifts (Saturday, Sunday) across regions.

Flows and formulas

The fields can be used in Flow conditions and formula fields like any other Date or Time field. For example, a formula for the local shift day that uses the actual start once clocked in:

BLANKVALUE(b3s__Site_Actual_Start_Date__c, b3s__Site_Scheduled_Start_Date__c)

Troubleshooting

Symptom Cause and fix
Fields are blank on older shifts The shifts predate the fields, or an org validation rule rejected them during the backfill (check the debug log for the backfill job). Fix the data and run the manual backfill.
Times are off by whole hours The Site's Timezone is wrong or blank (the org default was used). Check Site Timezone on the shift, correct the Site and wait for the re-stamp job.
A user can't see the fields Grant field-level read access through their permission set or profile.
An edit to a field is lost Expected. The fields are recalculated on every save. Change the source Date/Time field instead.