Timesheeting app

Timesheeting is a pair of portable, portal-hosted apps that close the loop between what was scheduled and what actually happened. Candidates confirm the hours they worked and log expenses; client reviewers approve, reject or query them. Both surfaces are built from one shared bundle and driven entirely by Custom Metadata configuration, so the object model, scoping, forms and per-status permissions are all things an admin or integrator can change without code.

What it is and the problem it solves

A shift that was rostered is only a plan. Before anyone can be paid or billed, someone has to confirm the actual start and end times, record breaks and tasks, capture any expenses, and get a client-side sign-off. Timesheeting provides the two ends of that exchange:

Both surfaces read and write the same underlying records. The difference between them is which records each can see (scope) and what each is allowed to do to a record at a given approval status (permission gates). That single-source design means there is no hand-off copy, no reconciliation, and no risk of the two sides drifting.

The two surfaces

Surface App type Who uses it Runs as
Candidate submission Timesheet Submission Candidates confirming worked time and logging expenses Portal guest + session key, scoped to the candidate's Contact
Client approval Timesheet Approval Client or account reviewers approving worked time across their people Portal guest + session key, scoped to the reviewer's accounts

How each runs

Both apps are hosted as portal pages served to Site Guest Users. Each request needs a valid session key that identifies one Contact, and the apps act only for that Contact. Scope is applied server side by each app definition's selectionClause:

Because the scope is applied server side and anchored to accounts, a reviewer never sees a timesheet outside their accounts, and a candidate never sees anyone else's.

Access profiles on approval

Timesheet Approval does not require an access profile. A reviewer without one (on the Contact or any Account Membership) is scoped to their own Account. A reviewer with a profile is governed:

The 12.11.0 Timesheet Approval sample also loads jobs owned by the direct parent of an account the reviewer acts for. For example, a school reviewer can see the trust's job on a school timesheet. The Timesheets Tab and Approve Timesheets permissions still govern which records the reviewer can open and approve.

Timesheet Submission has no write rules for profiled contacts, so do not give candidates a User Profile. See VMS access profiles and account memberships.

Embedded in the Client Shift Manager

The Client Shift Manager's VMS view has a Timesheets tab (profile checkbox Tab_Timesheets__c) that embeds Timesheet Approval in a frame, signed in as the same contact with the same session key and theme. It uses this app's own Component Configuration, so deploy the Timesheet Approval configuration even if you only use the embedded tab. The tab passes the Client Shift Manager's account selection through, so a multi-account reviewer can narrow timesheets to one school. See Client Shift Manager app.

The submission-then-approval lifecycle

The whole workflow turns on one field, b3s__Approval_Status__c, which moves through these states:

Status Meaning Candidate can Reviewer can
null (blank) Draft, not yet submitted Edit, delete, submit Approve, reject (sample config, shifts and expenses: no submission step needed); drop the isnull selector to require submission
Submitted Sent for review Nothing (locked) Approve, reject, query, edit
Approved Signed off Nothing (locked) Unapprove with a reason, when canUnapprove is configured and the shift is not yet interpreted for payroll
Rejected Sent back with a reason Edit and re-submit Nothing until re-submitted
Queried Flagged with a question Edit and re-submit Approve, reject, edit

The flow:

  1. A shift arrives in the candidate's list (from the scheduler, the clock app, or a VMS placement) with a blank approval status. The candidate confirms actual times, adds breaks/tasks, attaches evidence, then submits. The submit action stamps Submitted.
  2. The record now appears on the approval surface. The reviewer approves (stamps Approved, captures an approver signature), rejects (stamps Rejected, a reason is required), or queries (stamps Queried, a question is required).
  3. Approved records are locked on both sides and flow on to pay and bill. Rejected or Queried records return to the candidate as editable, and the cycle repeats.
  4. A reviewer who approved by mistake can Unapprove (when the definition sets canUnapprove): the shift goes back to Submitted with a reason, ready for a fresh decision. Once the shift is interpreted for payroll the server refuses the change and the error is shown; finance must unprocess it first.

The same status field gates permissions on both surfaces, from opposite directions, which is what keeps the two apps consistent without any shared state beyond the record itself.

Named approvers and two-step approval

A Job or Site can name its approving contacts per step with Timesheet Approver records. Shifts of that job or site then load only for those contacts, need one or two approvals in order (a step 1 approval leaves the shift Submitted at step 2, shown as Awaiting 2nd approval), and can trigger scheduled reminders. Shifts whose job requires client approval but not worker submission are submitted automatically when their Actual End is set, whether or not approvers are named. The shift definition keys approvalStatusFieldPath, approvalStepFieldPath and approvalStepsRequiredFieldPath drive the step indicator on the cards. With no approver rows, the lifecycle above is unchanged. See Timesheet approvers and multi-step approval.

Server-side protection of the approval status

b3s__Approval_Status__c (Shift and Expense) is a protected field for every portal session, whatever the definition allows:

Session May write Approval Status
Timesheet Submission, Clock (worker apps) Only Submitted, or clear it
Timesheet Approval, governed reviewer Any value, through the Approve Timesheets rule (see Access profiles on approval)
Timesheet Approval, ungoverned reviewer (no access profile) Any value
Client Shift Manager, Vendor Portal, kiosks Never

A blocked save fails with Your profile does not allow changing protected fields (approval status, VMS counters) of [<object>].

Reasons, comments and stamps

The worker's comment stays in b3s__Comments__c (Shift) or b3s__Submitter_Comments__c (Expense). A rejection writes its reason to Rejection Reason (b3s__Rejection_Reason__c) and a query its question to Query Comment (b3s__Query_Comment__c), so the worker's text is never overwritten. The shipped Timesheet Submission and Timesheet Approval definitions list both fields in the card title (hideIfNull: true), so the worker sees the reason next to their own comment.

Every transition is stamped by the Shift trigger: Submitted_Date__c / Submitted_By_Contact__c, Approved_Date__c / Approved_By__c (internal user) / Approved_By_Contact__c (portal contact) / Approval_Source__c, and Rejected_Date__c / Rejected_By__c / Rejected_By_Contact__c. Expenses get Approved_Date__c, Approved_By__c and Approval_Source__c. Approval Status is history tracked on both objects.

Once a shift is interpreted for payroll it is locked server side: changing its approval status or times needs a finance permission, and portal sessions are always refused (see Shift management studio, Lifecycle and locking). An approved expense only changes status and reason until it is unapproved. Once the pay/bill run has interpreted it, it is locked like a payrolled shift. The Timesheet Submission sample expense form carries a hidden b3s__Treatment__c field (default Payable and Billable) so the treatment is the admin's choice; see Pay and bill engine, Expenses.

How the apps are configured

Each surface is one b3s__Component_Configuration__mdt record whose b3s__Type__c is Timesheet Submission or Timesheet Approval, with the app definition in b3s__JSON__c. Both share the same JSON shape; see the app definition JSON reference for the full grammar and the record form field reference for field types.

Top-level options

Key Controls Submission Approval
timezonePreference Display timezone (client = site local) client client
defaultLanguage / availableLanguages i18n and the language switcher en-GB / en-GB,es-ES same
firstDay First day of the week (0 = Sunday, 1 = Monday) 0 1
defaultView Period the date navigation opens on: daily, weekly or monthly. Blank = weekly. Users can still switch with the Day / Week / Month buttons weekly weekly
is24Hour 24-hour clock true true
syncTimeout Background refresh interval, seconds. Approval reloads the current period on every tick 15 15
canChangeView Toggle daily/weekly view true true
canAddShifts / canAddExpenses Allow creating new rows true / true (omitted, reviewers do not create)
canSubmitShiftsForApproval / canSubmitExpensesForApproval Show the submit action true / true (n/a)
schedulables The object model (shift, expense, break, task) yes yes

The schedulables

Four schedulables are declared. break and task are minimal (objectType only) because they only ever appear as children inside a shift form. shift and expense carry the bulk of the configuration.

Schedulable Object Role
shift b3s__Shift__c Primary timesheet record: scheduled, actual and absolute times, status, approval status
expense b3s__Expense__c Standalone expense: date, category, currency, value, approval status
break b3s__Break__c Child of a shift, rendered inline
task b3s__Shift_Task__c Child of a shift, rendered inline

The shift schedulable maps a rich set of field paths so the app can distinguish scheduled from actual from absolute time and display everything in site-local time:

"shift": {
    "objectType": "b3s__Shift__c",
    "scheduledStartFieldPath": "b3s__Scheduled_Start_Time__c",
    "scheduledEndFieldPath": "b3s__Scheduled_End_Time__c",
    "actualStartFieldPath": "b3s__Actual_Start_Time__c",
    "actualEndFieldPath": "b3s__Actual_End_Time__c",
    "absoluteStartFieldPath": "b3s__Absolute_Start_Time__c",
    "absoluteEndFieldPath": "b3s__Absolute_End_Time__c",
    "siteTimezoneFieldPath": "b3s__Work_Site__r.b3s__Timezone__c",
    "statusFieldPath": "b3s__Status__c",
    "contactFieldPath": "b3s__Contact__c",
    "totalHoursFieldPath": "b3s__Absolute_Length__c"
}

The expense schedulable is date-anchored rather than time-window-anchored, and bounds how far the app looks around the selected date:

"expense": {
    "objectType": "b3s__Expense__c",
    "startFieldPath": "b3s__Date_of_Expense__c",
    "endFieldPath": "b3s__Date_of_Expense__c",
    "isFieldPathDateType": true,
    "contactFieldPath": "b3s__Contact__c",
    "lookBackLimitDays": 14,
    "lookForwardLimitDays": 14
}

Scope: selectionClause

The selectionClause is the server-side WHERE scope for each schedulable. It defines which records each user can see.

Submission (candidate sees only their own):

"selectionClause": [ "b3s__Contact__c = :contactUserId" ]

Approval (reviewer sees timesheets reachable through their accounts, three OR-joined paths):

"selectionClause": [
    "b3s__Contact__c != null AND b3s__Work_Job__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)",
    "b3s__Contact__c != null AND b3s__Work_Site__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)",
    "b3s__Contact__c != null AND b3s__Contact__c IN (SELECT b3s__Contact__c FROM b3s__Working_Pattern__c WHERE Id != null AND (b3s__Job__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c) OR b3s__Site__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)))"
]

The approval expense scope uses the expense's own Placement, with a fallback for expenses that have none:

"accountFieldPaths": ["b3s__Working_Pattern__r.b3s__Job__r.b3s__Account__c", "b3s__Working_Pattern__r.b3s__Site__r.b3s__Account__c"],
"selectionClause": [
    "b3s__Working_Pattern__r.b3s__Job__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)",
    "b3s__Working_Pattern__r.b3s__Site__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)",
    "b3s__Working_Pattern__c = null AND b3s__Contact__c IN (SELECT b3s__Contact__c FROM b3s__Working_Pattern__c WHERE Id != null AND (b3s__Job__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c) OR b3s__Site__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c)))"
]

The Placement (b3s__Working_Pattern__c, label Placement) is stamped automatically on create when exactly one of the worker's placements covers the expense date. The third clause keeps legacy and ambiguous expenses visible.

:accountIds(<checkbox>) resolves to the accounts whose profile grants that checkbox, or to the reviewer's own Account when they have no profile. If your configuration uses =:contextUser.AccountId, replace it with IN :accountIds(...) to support multi-account reviewers.

Note the != null guards: a timesheet with no Contact is never surfaced to a reviewer.

Period anchor and earlier timesheets

The approval sample loads shifts by their site-local work date, b3s__Site_Work_Date__c (the scheduled date, or the actual date for ad hoc shifts), with Monday weeks (firstDay: 1), the same anchor the Shift management studio and invoicing use. An overnight Sunday to Monday shift therefore sits in the same week everywhere:

"absoluteStartFieldPath": "b3s__Absolute_Start_Time__c",
"dateFilterFieldPath": "b3s__Site_Work_Date__c",
"isFieldPathDateType": true

dateFilterFieldPath drives both the server-side date window and the day tabs; the absolute, scheduled and actual paths still drive what the cards show. Leave it out to keep the previous behaviour (window on absoluteStartFieldPath).

A timesheet submitted late for an earlier week would otherwise stay invisible unless the reviewer browsed back. When the shift schedulable declares outstandingClause, the approval page also loads earlier shifts still awaiting a decision and shows a banner, "N earlier timesheets need your decision", with Show / Hide. Shown, they appear in their own list above the current period, and Approve All / Reject All include them; hidden, the bulk buttons cover the current period only. The sample repeats the three account scopes with the pending condition:

"outstandingClause": [
    "b3s__Contact__c != null AND b3s__Work_Job__r.b3s__Account__c IN :accountIds(b3s__Tab_Timesheets__c) AND b3s__Approval_Status__c IN ('Submitted','Queried') AND b3s__Absolute_Start_Time__c < :contextStart+1d"
]

The clause owns its date bound (the period window is not added), and the page keeps only shifts whose work date is before the current period. See Data loaders, Schedulable clause sets. Shifts created more than two days after their work date are also flagged Late Entry (b3s__Is_Late_Entry__c, stamped on insert) for reports.

Per-status permission gates

Each schedulable declares condition blocks that gate row-level actions on the record's current approval status. A condition has allOrSome (some = OR, all = AND) and a list of selectors (field, operator, value). A boolean literal ("canDelete": false) hard-disables an action.

On the submission surface, the candidate can edit or re-submit while a record is unstarted or bounced back, and can only delete a genuinely untouched draft:

"canEdit": {
    "condition": {
        "allOrSome": "some",
        "selectors": [
            { "field": "b3s__Approval_Status__c", "operator": "isnull", "value": true },
            { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Rejected" },
            { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Queried" }
        ]
    }
},
"canDelete": {
    "condition": {
        "allOrSome": "all",
        "selectors": [
            { "field": "b3s__Approval_Status__c", "operator": "isnull", "value": true }
        ]
    }
}

canSubmitForApproval uses the same null/Rejected/Queried set. Once a record is Submitted or Approved, all three actions are false, so the candidate cannot touch it.

On the approval surface, the reviewer can approve or reject a blank, Submitted or Queried record and can never delete. The blank selector lets clients approve shifts and expenses nobody submits (accounts without Requires_Worker_Submission__c / Requires_Vendor_Submission__c; those flags only raise Studio exceptions, they do not gate approval). Remove it on both shift and expense to make submission mandatory:

"canApprove": {
    "condition": {
        "allOrSome": "some",
        "selectors": [
            { "field": "b3s__Approval_Status__c", "operator": "isnull", "value": true },
            { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Submitted" },
            { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Queried" }
        ]
    }
},
"canDelete": false

An Approved record satisfies neither side's gates, so it is final everywhere. This pair of opposing gate sets, over one field, is the entire concurrency model.

List display: title and weekly view

The title array defines the summary shown per row. Entries carry a fieldPath, an optional formatter, a siteTimezoneFieldPath for local rendering, and hideIfNull. Composite time fields join two paths with a colon:

{
    "label": "Scheduled Times",
    "fieldPath": "b3s__Scheduled_Start_Time__c:b3s__Scheduled_End_Time__c",
    "formatter": "startEndWithDate",
    "siteTimezoneFieldPath": "b3s__Work_Site__r.b3s__Timezone__c",
    "hideIfNull": false
}

title entries can also be nested child summaries ("type": "break" / "type": "task") that render break and task times inline under the shift, joined by childField/parentFieldPath. The submission surface additionally configures a weekly grid via weeklyViewRowFields (grouping columns), weeklyViewTitle (row header) and weeklyViewRecordFields (inline editors such as an actual-times range and job/site selects), so a candidate can fill a week at a glance.

How the weekly grid behaves:

Consolidated approval view: consolidation

A large client can have hundreds of shifts in a week, and one card per shift makes a very long page. When a schedulable declares consolidation, the records list shows a Summary / Individual toggle. Summary is the default, and each viewer's choice is remembered in their browser per records type.

"consolidation": {
    "groupBy": [
        { "fieldPath": "b3s__Contact__c", "labelFieldPath": "b3s__Contact__r.Name" },
        { "fieldPath": "b3s__Work_Job__c", "labelFieldPath": "b3s__Work_Job__r.Name" }
    ],
    "totalFieldPath": "b3s__Absolute_Length__c",
    "totalLabel": "Hours",
    "title": [ { "label": "Site", "fieldPath": "b3s__Work_Site__r.Name", "hideIfNull": true } ]
}

The edit form: recordFormFields

recordFormFields is the full edit form. It supports separators (isSeparator), multi-column layout (columns), conditional visibility (showIf), conditional disabling (disabled as a condition block), defaults (including context tokens like :contextId, :contactUserId, :contextStart, :contextEnd, :contextDate), option loaders, and nested child blocks. A representative slice of the submission shift form:

{
    "field": "b3s__Actual_Start_Time__c:b3s__Actual_End_Time__c",
    "valueStart": ":contextStart",
    "valueEnd": ":contextEnd",
    "labelOverride": "Actual Times",
    "type": "field-time-range-selector",
    "props": { "hideDate": false },
    "columns": "col-span-2"
},
{
    "field": "b3s__Work_Job__c",
    "type": "field-select",
    "loader": "jobs",
    "optionLabelField": "Name",
    "optionsInPopout": true,
    "optionExtendedDetails": [
        { "label": "Account", "targetField": "b3s__Account__r.Name" },
        { "label": "Position", "targetField": "b3s__Job_Group__r.Name" }
    ],
    "views": { "blukCreateView": true }
}

Field types in play across the two definitions include field-time-range-selector, field-select (with loader for options), field-text-area, field-date-input, field-number-input, field-file-upload, field-signature, record-files-manager, and nested task / break blocks with their own recordFormFields. Some selects narrow their options relative to another field via showOptionIf (for example, only offering placements whose Contact and Job match the record). The views.blukCreateView flag marks a field for the bulk-create path.

The two surfaces reuse the same form skeleton but flip the disabled flags: submission fields are editable, the corresponding approval fields set disabled: true, so a reviewer reads the timesheet but does not rewrite the candidate's entries.

Action mini-forms

Beyond the main edit form, small dedicated forms drive the status transitions. Each pins b3s__Approval_Status__c to a fixed, hidden value and collects only what that action needs:

Query and Unapprove follow the same access rule as Approve: a profiled reviewer needs Approve Timesheets on the timesheet's account. The shipped sample gates them like this:

"canQuery": { "condition": { "allOrSome": "some", "selectors": [
    { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Submitted" } ] } },
"canUnapprove": { "condition": { "allOrSome": "all", "selectors": [
    { "field": "b3s__Approval_Status__c", "operator": "equals", "value": "Approved" },
    { "field": "b3s__Pay_Bill_Status__c", "operator": "notequals", "value": "Interpreted" } ] } }

Holding the client bill. The sample approval form also offers Hold the client bill (b3s__Bill_Hold__c) with a required Bill hold reason (b3s__Bill_Hold_Reason__c) shown when it is ticked. The shift is approved and the worker is paid as usual, but its client bill and vendor self-bill wait until the hold is released in the Shift management studio. Remove the two entries from recordFormFieldsApproval if reviewers should not hold bills.

"recordFormFieldsRejection": [
    { "field": "b3s__Approval_Status__c", "type": "field-select", "hidden": true, "default": "Rejected" },
    { "field": "b3s__Rejection_Reason__c", "labelOverride": "Reason", "type": "field-text-area", "required": true }
]

Use b3s__Rejection_Reason__c on expenses too. Definitions created before this release write the reason to b3s__Comments__c / b3s__Submitter_Comments__c, which overwrites the worker's comment; switch the field to keep both. Card title entries for the worker:

{ "label": "Rejection Reason", "fieldPath": "b3s__Rejection_Reason__c", "hideIfNull": true },
{ "label": "Query", "fieldPath": "b3s__Query_Comment__c", "hideIfNull": true }

Reference data: loaders

Option lists for the selects come from b3s__Component_Loader__mdt records linked to each configuration; the frontend never builds these queries, it only names a loader ("loader": "jobs"). Each surface ships its own set, differing only in scope. See data loaders for the loader JSON contract.

Loader Object Submission scope Approval scope
contacts Contact Id = :contextId Contacts placed at the reviewer's Account
jobs b3s__Job__c Jobs the candidate is placed on b3s__Account__c IN :accountIds
sites b3s__Site__c Sites the candidate is placed at account-scoped
placements b3s__Working_Pattern__c b3s__Contact__c = :contextId placements under the reviewer's Account
locations b3s__Site_Location__c Locations of the candidate's sites account-scoped

Submission loaders anchor on :contextId (the signed in candidate); approval loaders anchor on :accountIds (the reviewer's accounts). Example submission jobs loader:

{
    "name": "jobs",
    "objectName": "b3s__Job__c",
    "filterRecordsBy": [
        "Id IN (SELECT b3s__Job__c FROM b3s__Working_Pattern__c WHERE b3s__Contact__c =:contextId)"
    ],
    "groupRecordsBy": "Id",
    "fieldToLoad": ["Name", "b3s__Job_Group__c", "b3s__Job_Group__r.Name"]
}

Where timesheeting sits in the platform

Timesheeting is the confirmation and sign-off stage in the workforce lifecycle:

Because approval locks the record on both sides, pay and bill always draws from an immutable, client-signed source.

What an integrator can configure

Everything above lives in the two b3s__Component_Configuration__mdt records and their loader records. Common changes: