Scheduled jobs

Scheduled jobs

Some WFM features run on a timer: for example the timesheet approval reminders go out every Monday at noon. The Scheduled Jobs tab lets an admin set these up, see when they next run, run one immediately and stop them, all without Developer Console or anonymous Apex.

The tab only shows and manages WFM jobs that are registered for it. Other scheduled Apex in the org (yours, or other packages') is never listed and cannot be stopped from here; use Setup > Scheduled Jobs for those.

Access

Item Details
Tab Scheduled Jobs (b3s__Scheduled_Jobs), in the 3B WFM and 3B VMS apps
Component Lightning web component b3s:scheduledJobs (also placeable on any App page)
Custom permission WFM Manage Scheduled Jobs (b3s__Manage_Scheduled_Jobs)
Granted by Permission set WFM Admin

Every action is checked on the server against the custom permission. A user without it sees the error "You need the WFM Manage Scheduled Jobs permission to manage scheduled jobs." even if they reach the tab.

The jobs list

The top card lists every scheduled WFM job, with:

Column Meaning
Type The registered job type, for example Timesheet approval reminders
Name The unique name given when the job was scheduled. Pick names that say what the job does, such as "Timesheet approval reminders - Step 2 - Ready mode" (the default)
Schedule The schedule in plain words ("Mondays at 12:00", "Every hour at :00"). Shapes the simple builder does not produce read "Custom schedule"
Cron The raw cron expression
Next run / Last run Shown in your time zone
State Salesforce's state for the job: WAITING (normal), ACQUIRED / EXECUTING (running now), PAUSED, ERROR, COMPLETE
Time zone The time zone the cron runs in: the time zone of the user who scheduled it
Scheduled by The user who scheduled the job. The job runs as this user

Stop asks for confirmation and deletes the schedule. The job does not run again; schedule it again to restart it. A run that already started finishes.

The list does not show a job's parameter values (Salesforce does not expose them). The default job name includes them, which is why it is worth keeping.

Scheduling a job

  1. Open the Scheduled Jobs tab.
  2. In Schedule a job, pick the Job. Its description and its settings appear underneath.
  3. Fill in the settings (for the reminders: Approval step and Ready mode).
  4. Pick the schedule, one of three ways:
    • Suggested: a ready-made schedule for this job. Picking one also fills in the settings it is meant for.
    • Simple: every hour (at a minute past the hour), every day at a time, or every week on chosen days at a time.
    • Cron expression: any Salesforce Apex cron expression, for example 0 0 8 ? * MON-FRI.
  5. Check the Runs: line, which repeats the schedule in plain words with its cron expression.
  6. Check or change the Job name (unique across the org's scheduled jobs, 255 characters at most).
  7. Click Schedule. The new job appears in the list.

Time zones

A Salesforce scheduled job runs in the time zone of the user who schedules it. The form says which time zone that is (your user's time zone setting). An admin in London who schedules "Mondays at 12:00" gets 12:00 London time, even for approvers in Sydney. To run at a time that suits another region, either have a user in that time zone schedule it, or convert the time yourself.

Run once now

Run once now runs the selected job immediately, once, with the settings on the form (the schedule and name are ignored). It asks for confirmation because it does the job's real work: the reminder job sends real messages. The work happens in the background; check Setup > Apex Jobs for the result.

Errors

Message Cause
Invalid schedule "...": ... The cron expression is not valid Salesforce Apex cron. The rest of the message is Salesforce's explanation
A scheduled job named "..." already exists Names must be unique in the org, including jobs not managed here
Enter a value for ... / Invalid value "..." for ... A required setting is empty, or a value is not one of its choices
Ready mode notifies step 2 approvers only The job refused the combination of settings (here: ready mode on step 1)
This scheduled job is not one of the WFM jobs managed here The job is not a registered WFM job type, so it cannot be stopped from this tab

Cron expressions

Salesforce Apex cron has six or seven fields: Seconds Minutes Hours Day_of_month Month Day_of_week [Year]. Use ? in either day field when the other one is set.

Expression Runs
0 0 12 ? * MON Mondays at 12:00
0 0 10 ? * TUE,THU Tuesdays and Thursdays at 10:00
0 30 8 ? * MON-FRI Monday to Friday at 08:30
0 0 6 * * ? Every day at 06:00
0 0 * * * ? Every hour on the hour

Salesforce runs a job at most once an hour through a single cron expression. For more frequent runs, schedule several jobs at different minutes.

Registered jobs

Timesheet approval reminders

Sends each timesheet approver one message listing the shifts waiting at their approval step. Setup (approvers, templates, the approvalReminders configuration block) is described in Timesheet approvers.

Setting Values Notes
Approval step Step 1, Step 2 Which approvers to remind
Ready mode (step 2 only) On / off Instead of a reminder, tell step 2 approvers once step 1 is done. Refused on step 1
Suggested schedule Settings Cron
Step 1 reminder, Mondays 12:00 Step 1 0 0 12 ? * MON
Step 2 reminder, Tuesdays 10:00 Step 2 0 0 10 ? * TUE
Step 2 ready notice, every hour Step 2, ready mode 0 0 * * * ?

Apex class: b3s.TimesheetApprovalReminderJob.

How it works