Timesheet approvers and multi-step approval

Timesheet approvers and multi-step approval

By default a client timesheet is approved once, by any reviewer at the client account who can see it in Timesheet Approval (see Timesheeting app). Many clients need more control than that:

Timesheet Approvers add all three. An admin lists, per Job or per Site, which client contacts approve at step 1 and (optionally) step 2. The shift and expense triggers work out which list applies to each record, record it there, and enforce the order of approval on the server. A scheduled job sends each approver one message listing the timesheets and expenses waiting for them.

Expenses follow the same process. An expense on a placement uses the approvers of the placement's job (else its site), with the same steps, rules and restarts as a shift. See Expenses.

Without any Timesheet Approver rows nothing changes: shifts and expenses are approved once, account-wide, exactly as before. Two org-wide switches turn the features off: see Org switches.

Quick start

  1. Open a Job (or a Site) and add rows to the Timesheet Approvers related list: one row per approving contact, with Step 1 or 2.
  2. Make sure each approver has access to Timesheet Approval (a portal session, or a licensed community user, with Timesheets Tab and Approve Timesheets on their access profile for the job's account when they are governed).
  3. Optional: create the reminder templates (see Templates and languages), add an approvalReminders block to the Timesheet Approval configuration and schedule the reminders on the Scheduled Jobs tab (see Reminders).

That is all. Existing unapproved shifts of that job or site pick up the new route within minutes (a background batch re-stamps them).

Data model

Timesheet approver object

Object b3s__Timesheet_Approver__c, tab Timesheet Approvers (in the 3B WFM and 3B VMS apps), related lists on the Job and Site page layouts. Records are numbered TA-00001. Sharing: Public Read/Write internally, Private externally.

Field API name Type Notes
Contact b3s__Contact__c Lookup(Contact) The approving client contact. Required (validation rule Contact_Required).
Job b3s__Job__c Lookup(Job) Set for a job-level approver.
Site b3s__Site__c Lookup(Site) Set for a site-level approver. Exactly one of Job or Site (validation rule Job_Or_Site).
Step b3s__Step__c Picklist 1, 2 Required. Step 1 approves first, step 2 after step 1.
Active b3s__Active__c Checkbox, default true Inactive rows are ignored: they neither approve nor receive reminders.
Last Notified b3s__Last_Notified__c DateTime Stamped by the reminder job each time it messages this approver. Read only in practice.

A pool is the set of active rows for one Job (or one Site) and one step. Any one member of a pool completes that step for the shift.

Fields stamped on Shift

All five fields are set by the server. They are read only on the Shift page layout and in the shipped permission sets (WFM Admin can edit them, for data repair only).

Field API name Type Meaning
Approver Level b3s__Approver_Level__c Picklist Job, Site Which pool applies. Blank = no approvers, legacy single account-wide approval.
Approval Steps Required b3s__Approval_Steps_Required__c Number The highest active Step in that pool (1 or 2). Blank when Approver Level is blank.
Approval Step b3s__Approval_Step__c Number The step currently waiting for approval. Blank when no approvers apply.
First Approved By Contact b3s__First_Approved_By_Contact__c Lookup(Contact) Who completed step 1 of a two-step chain.
First Approved Date b3s__First_Approved_Date__c DateTime When step 1 was completed.

The same five fields exist on Expense (see Expenses).

The final approval keeps using the existing approval stamps (Approved By Contact, Approved Date, Approval Source; see Shift management studio, Approval audit).

Which approvers apply to a shift

The shift's Job has active approver rows The shift's Site has active approver rows Approver Level Who approves
Yes Yes or no Job The Job's pools only
No Yes Site The Site's pools
No No blank Anyone allowed today (account-wide, single step, unchanged)

Job approvers win over site approvers completely: a job with only a step 1 row is a one-step job, even if its site has two steps.

The route is stamped on the shift when:

When the re-stamp batch moves a shift to another pool, or to fewer steps than the step it was waiting at, its chain restarts at step 1. When no approvers are left, the shift falls back to legacy approval.

How approval works

Single step (Step 1 rows only)

A shift with Approval Steps Required = 1 is approved once, but only by a member of the step 1 pool. Anyone else at the account who tries to approve it gets You are not an approver for approval step 1 of this shift.

Two steps

  1. The worker submits (or the shift is auto-submitted). Approval Status Submitted, Approval Step 1.
  2. A step 1 approver approves in Timesheet Approval. The server stores the shift as Submitted at Approval Step 2 (not Approved) and stamps First Approved By Contact and First Approved Date. The card now reads Awaiting 2nd approval.
  3. A step 2 approver approves. The shift becomes Approved and flows on to pay and bill as usual.

Rules enforced on the server for portal and community approvals:

What restarts the chain at step 1

Event Result
Reject, Query, Resubmit or Unapprove (any Approval Status change other than an approval) Approval Step back to 1, First Approved By / Date cleared
Job or Site changed Route re-stamped, chain restarts
Actual Start or Actual End changed while the shift waits at step 2 Chain restarts: the step 1 approver must see the new times
Re-stamp batch moved the shift to another pool or below its current step Chain restarts

Internal users and automation approve in one go

Internal (Standard licence) users, for example finance in the Shift management studio, approve a pooled shift in one action, at any step, without being in a pool. This is the override and escalation path when an approver is away. The approval is stamped with Approval Source Internal (or Internal on behalf of Client from the studio's on-behalf action), so reports can tell it apart from a client approval.

Automation with no acting contact (a Flow or Apex running as an internal or integration user) also approves in one go.

What approvers see in Timesheet Approval

The shipped configuration scopes each approver to their own pools:

Each card in a two-step chain shows an Approval row: Step 1 of 2, or Awaiting 2nd approval at step 2. Approved shifts show none. The shipped card also lists First approved by. After every approve or reject the list is reloaded from the server, because an approval at step 1 leaves the shift Submitted.

Bulk approve runs record by record. If one record fails (for example a step the contact is not in), the error is shown and the records saved before it are reloaded behind the modal.

Expenses

An expense (b3s__Expense__c) runs the same chain, with the same pools, the same five fields and the same error messages.

Ceiling: when a placement's own Job or Site changes later, its existing expenses keep the old values until they are saved again.

Org switches

Two checkboxes on the Scheduler hierarchy custom setting (b3s__Scheduler__c, Setup > Custom Settings > Scheduler > Manage), both off by default. They are read once per transaction for the running user (getInstance()), so a profile- or user-level value overrides the org default.

Field When ticked
Disable Timesheet Approval Chain (b3s__Disable_Timesheet_Approval_Chain__c) Timesheet Approvers are ignored. There are no pool checks and no re-stamp, and one approval from anyone allowed to approve timesheets for the account is final. Every shift or expense saved while it is ticked has its five chain fields cleared (unless it was already Approved, which keeps its history), so the legacy Approver_Level__c = null portal clauses show it to account reviewers again. Open records nobody saves keep their old stamps (and stay hidden from account reviewers) until they are next saved, so save them (for example a mass edit of the open shifts and expenses) after ticking it. Untick it to go back: routes are stamped again when a record is next submitted or moved, or when an approver row changes.
Disable Timesheet Auto-Submit (b3s__Disable_Timesheet_Auto_Submit__c) Recording a shift's Actual End no longer submits it (Auto-submit).

Both are shown, read only, on the Workflow settings card.

Auto-submit when the worker does not submit

When Actual End is set on a shift for the first time and the shift has no Approval Status yet, the server submits it automatically if its job:

The shift goes straight to Submitted (and into the step 1 queue when approvers apply), so the client can approve without waiting for a submission nobody will make.

Behaviour change. This applies to every org with that combination of settings, with or without Timesheet Approvers. Actual End is set by a Clock app clock-out, a Terminal clock-out, a third-party clock (Time capture integration), a Timesheet Submission save, an import, or an internal user editing times. From this release those shifts arrive in Timesheet Approval already Submitted (the worker can no longer edit them from Timesheet Submission, whose sample gates allow edits only while Approval Status is blank). Orgs that relied on a blank status until someone acted should turn on Requires Worker Submission for those jobs or accounts.

Shifts with no Job, shifts that already have an Approval Status, and later edits to an Actual End that was already set are not auto-submitted. Tick Disable Timesheet Auto-Submit on the Scheduler custom setting to turn auto-submit off for the org (see Org switches).

Reminders

b3s.TimesheetApprovalReminderJob sends each approver one message listing the shifts and expenses waiting for their step. It is a global, schedulable class: you schedule it once per step at the times you want.

How a reminder run works

  1. Finds Submitted shifts (with a worker) and Submitted expenses at the job's step that have a pooled route (Approver Level set), oldest first, up to 10,000 of each per run.
  2. Groups them by Job or Site pool and matches the active approvers of that step.
  3. Renders one message per approver (a contact in several pools gets one message covering all their shifts and expenses) in the approver's language. An approver with only expenses waiting gets a message too.
  4. Creates an Outbound Campaign (Source__c = Scheduled, Rule__c = timesheet_approval_step_<n> or timesheet_approval_ready_step_2) with one Outbound Notification per approver, and hands it to the Bulk Notification Engine's send job. Push is dispatched straight away.
  5. Stamps Last Notified on every approver row it messaged.

Because delivery goes through the Bulk Notification Engine, every channel your org has set up works: native Email, Push, and Flow or Apex plugin channels such as SMS, WhatsApp or SendGrid (see Scheduling notifications). Campaigns and notifications are ordinary records: report on them, or open them to see what was sent.

Shifts with no approvers (legacy account-wide approval) never produce reminders. When nobody is waiting, the run creates nothing.

Reminder mode and ready mode

Mode Constructor Who is messaged
Reminder new b3s.TimesheetApprovalReminderJob(1) or (2) Every active approver of that step whose pool has Submitted shifts waiting at that step. Sent every time the schedule fires.
Ready (step 2 only) new b3s.TimesheetApprovalReminderJob(2, true) Step 2 approvers of a pool that has no Submitted step 1 shifts or expenses left, and only when at least one of its records had step 1 approved after the approver's Last Notified. Each batch of step 1 approvals is announced once.

Ready mode lets you schedule an hourly check that says "step 1 is done, your turn" as soon as the line manager finishes, instead of waiting for the next fixed reminder. Any step 2 message (reminder or ready) moves Last Notified, so a ready notice is not repeated for step 1 approvals already covered by a reminder. Ready mode uses the step 2 template.

Scheduling

Schedule the reminders from the Scheduled Jobs tab (3B WFM or 3B VMS app; needs the WFM Manage Scheduled Jobs custom permission, granted by WFM Admin). See Scheduled jobs for the full guide.

  1. Open Scheduled Jobs and, under Schedule a job, pick Timesheet approval reminders.
  2. Pick a Suggested schedule: Step 1 reminder, Mondays 12:00, Step 2 reminder, Tuesdays 10:00 or Step 2 ready notice, every hour. This also sets Approval step and Ready mode. Or set them yourself and use the Simple builder or a cron expression.
  3. Keep or change the job name and click Schedule. Repeat for each schedule you want.

The list on the same tab shows the next and last run of each reminder job and has a Stop button. Run once now sends one round immediately (real messages) to test your setup.

Scripted setups can still schedule the class from Developer Console, Execute Anonymous, as the admin who should own the job. Jobs scheduled this way also appear on the tab:

// Step 1 approvers every Monday at 12:00
System.schedule('TS approval step 1', '0 0 12 ? * MON', new b3s.TimesheetApprovalReminderJob(1));
// Step 2 approvers every Tuesday at 10:00
System.schedule('TS approval step 2', '0 0 10 ? * TUE', new b3s.TimesheetApprovalReminderJob(2));
// Optional: hourly "step 1 is done" notice to step 2 approvers
System.schedule('TS approval ready', '0 0 * * * ?', new b3s.TimesheetApprovalReminderJob(2, true));

Configuration

Add a root approvalReminders block to the Timesheet Approval Component Configuration (b3s__Component_Configuration__mdt, field b3s__JSON__c). The shipped sample:

"approvalReminders": {
    "channels": ["Email"],
    "templateKeys": { "1": "timesheet_approval_step_1", "2": "timesheet_approval_step_2" },
    "link": "",
    "languageFieldPath": null,
    "maxShiftsPerMessage": 50
}
Key Required Notes
channels Yes Notification Channel developer names, for example ["Email", "Push", "SMS"]. Every message goes out on all of them.
templateKeys Yes Notification Template Key per step ("1", "2"). The plain key must exist and be active; it is the fallback language.
link No Deep link on every message (push click action, available to Flow channels as Link__c), for example your Timesheet Approval portal page. Max 255 characters.
languageFieldPath No A Contact field holding the recipient's language, for example b3s__Language__c. Leave it out (or null) to use the contact's active portal user language.
maxShiftsPerMessage No How many shifts the <repeat> block lists, and separately how many expenses <repeatExpenses> lists (default 50 each). The count tokens still report the full numbers.

Templates and languages

Templates are Notification Template records (b3s__Notification_Template__c), the same object the scheduler's Notification Center uses. Create one template per step, keyed as below, plus a row per language you support.

Translations are separate template rows whose Key is <key>:<language>:

Key Used for
timesheet_approval_step_1 Default (any language without its own row)
timesheet_approval_step_1:fr French, and any French locale (fr_CA, fr_FR) without its own row
timesheet_approval_step_1:fr_ca Canadian French only

The recipient's language is the Contact field named by languageFieldPath, else the LanguageLocaleKey of the contact's active portal user, else the plain key. Matching ignores case and treats - and _ alike, then falls back from fr_CA to fr, then to the plain key. A language row must be Active to be used.

Tokens (plain text, no HTML):

Token Value
{firstName}, {lastName} The approver contact
{contact.<fieldPath>} Any field of the approver contact, for example {contact.Account.Name}
{countShifts} All shifts waiting for this approver
{countChanges} Shifts listed in this message (capped by maxShiftsPerMessage)
<repeat> ... </repeat> Repeated once per listed shift
{record.<fieldPath>} Inside <repeat>: any shift field, for example {record.b3s__Contact__r.Name}
{countExpenses} All expenses waiting for this approver
<repeatExpenses> ... </repeatExpenses> Repeated once per listed expense (reminders only; the engine's single <repeat> stays for shifts)
{expense.<fieldPath>} Inside <repeatExpenses>: any expense field, for example {expense.b3s__Category__c}, {expense.b3s__Total_Value__c}

Example step 1 body (from the seed script):

Hi {firstName},

{countShifts} timesheet(s) are waiting for your approval:
<repeat>- {record.b3s__Contact__r.Name}, {record.b3s__Work_Site__r.Name}, {record.b3s__Absolute_Start_Time__c}
</repeat>
Please review them in the portal.

To list expenses as well, add a second block (an empty one renders nothing when no expense waits):

{countExpenses} expense(s) are waiting too:
<repeatExpenses>- {expense.b3s__Contact__r.Name}, {expense.b3s__Category__c}, {expense.b3s__Total_Value__c}
</repeatExpenses>

Date and time fields render in the timezone of the user who scheduled the job. To show the site's local time instead, use the site-local stamps, for example {record.b3s__Site_Scheduled_Start_Date__c} {record.b3s__Site_Scheduled_Start_Time__c} (see Shift site-local times).

Shift management studio

The studio shows the chain under the status badge of every multi-step shift: Step 2 of 2 ยท 1st: Jane Doe, 7 Jul while open, just the first approver once finished (hover for the full date and the pool level). The Awaiting final approval exception (awaitingFinalApproval) lists shifts where step 1 is done and step 2 is outstanding. An internal approval from the studio completes the chain in one go. See Shift management studio.

Security and access

Limits and known ceilings

Troubleshooting

Symptom Cause
You are not an approver for approval step 1 of this shift. The contact is not an active member of that pool (check the Job first: job rows win over site rows). A step 2 approver also gets this on a shift not yet submitted, because it is still at step 1.
You approved step 1 of this shift; step 2 needs a different approver. The contact is in both pools. Another step 2 member, or an internal user, must approve.
Approved, but the shift is still Submitted Step 1 was approved; the shift waits at step 2.
A reviewer no longer sees some timesheets Their jobs or sites now have approvers and they are in no pool. Add them, or remove the rows.
Approver Level stays blank after adding rows The re-stamp batch has not run yet, failed, or the row is inactive or missing a Contact or Step. Check Setup > Apex Jobs.
No reminder arrived The approver row is inactive, no Submitted shift waits at that step, the shift has no worker, the channel is not set up, or the scheduled run failed (Setup > Apex Jobs).
Reminder in the wrong language No active <key>:<language> row matches, or the language field / portal user language is blank.
Shifts arrive already Submitted Auto-submit: the job requires client approval and not worker submission. Tick Disable Timesheet Auto-Submit to stop it org-wide.
An expense has no Approver Level It has no placement, or the placement's job and site have no approvers.