A strategic business unit (SBU) is a division of your organisation, for example Healthcare, Industrial or Education. Multi-division agencies and master vendors use SBUs to:
Every org has at least one SBU, the default SBU, created automatically on install or upgrade. An org with one unit needs nothing else: the default SBU is simply where the invoice number series and the invoice letterhead live.
| Object | Purpose |
|---|---|
SBU (b3s__SBU__c) |
One record per business unit. Holds the code, the active and default flags, the legal entity details and the two number series. Tab: SBUs in the 3B WFM and 3B VMS apps. Sharing: Public Read Only. |
SBU Assignment (b3s__SBU_Assignment__c) |
Links one Account, Contact or User to an SBU. Accounts, workers and users can belong to several units. Exactly one of Account, Contact and User must be set (validation rule Exactly_One_Target); duplicates are refused through the unique Key__c (target Id + SBU Id, stamped automatically). Is_Primary__c marks the main unit. |
| Field | Use |
|---|---|
Name, Code__c |
Display name and a short unique code (for reports and integrations). |
Active__c |
Inactive units are no longer stamped on new records and are not offered in pickers. |
Is_Default__c |
Exactly one active unit is the default. Making another unit the default clears the previous one; the only default cannot be unticked. |
Disable_Pay_Bill_Estimates__c |
Opts the unit's shifts out of automatic pay/bill estimates while the global switch is on. |
Legal_Name__c, Trading_Name__c, Street__c, City__c, Province_State__c, Postal_Code__c, Country__c |
Legal entity name and address printed on invoices. Blank legal name = the SBU name. |
Company_Registration_Number__c, Tax_Registration_Number__c |
Printed on invoices; the tax number is also passed to tax plugins. |
Invoice_Email__c, Invoice_Phone__c |
Contact details printed under the address. |
Bank_Details__c |
Payment instructions printed on client invoices (never on self-bills). Restrict its field-level security to finance users. |
Logo_Document_Id__c |
ContentVersion (068...) or ContentDocument (069...) Id of the logo printed on the invoice header. |
Payment_Terms_Days__c |
Due date offset used when the invoice configuration has no payment terms. |
Invoice_Prefix__c, Last_Invoice_Number__c |
Client invoice and client credit note series. |
Self_Bill_Prefix__c, Self_Bill_Last_Number__c |
Self-bill and self-bill credit note series. |
Number_Padding__c |
Minimum digits after the prefix, zero-padded. 6 gives INV-000042; blank or 0 gives INV-42. |
Group_Id__c |
Read only. The unit's public group, created automatically in SBU mode (see Record visibility). |
Prefixes are unique across every unit and both series (case-insensitive).
| Object | Field | How it is set |
|---|---|---|
| Job | SBU__c |
By you. Required while SBU mode is on (validation rule SBU_Required_In_SBU_Mode). A job belongs to exactly one unit. |
| Account, Contact | SBU__c (primary unit) |
Kept in sync with the primary SBU Assignment in both directions: setting the field creates or promotes that unit's assignment; making an assignment primary writes the field. |
| Shift, Working Pattern, Booking Request, Expense | SBU__c |
Stamped automatically while SBU mode is on (see below). |
| Pay/Bill Staging | SBU__c |
Copied from the shift when the line is created. Corrections keep the original line's unit. |
| Pay/Bill Run | SBU__c |
The unit a run was limited to; blank = every unit. |
| Invoice | SBU__c |
Stamped at generate. Decides the number series and the PDF letterhead. Frozen once the invoice is numbered. |
| Invoice Configuration | SBU__c |
Optional unit scope of a configuration (see Invoice configuration per unit). |
Tagging and filtering are switched on by the WFM custom setting field SBU Mode (b3s__Scheduler__c.b3s__SBU_Mode__c, Setup > Custom Settings > WFM > Manage). It is off by default.
| SBU mode off | SBU mode on | |
|---|---|---|
| Work record stamping | None | Shift, Working Pattern, Booking Request, Expense |
| Job SBU | Optional | Required |
| Invoice split | Kind, bill-to, currency (+ category) | Plus SBU: one document never mixes units |
| Invoice SBU | The default SBU | The lines' unit (blank lines: the default SBU) |
:sbuIds clause token |
Unrestricted | The running user's units |
| Pay/Bill Runner, Invoice Generator, Studio | No SBU picker or filter | SBU picker / sbu filter |
Turning the mode on does not re-stamp existing records by itself. New and edited records are stamped from then on. Records already interpreted by the pay and bill engine are not back-filled on a plain save (the shift lock would refuse the change). Run the back-fill batch once to stamp and share existing data.
Shift, Working Pattern and Booking Request, first match wins:
b3s__Account__c) primary SBU.Expenses: the expense's shift unit, else its placement's unit (stamped, else derived as above), else the worker's primary SBU, else the default SBU.
The unit is computed on insert and whenever it is blank. On update it is recomputed only when the job or site (expense: shift, placement or worker) changes. A unit set explicitly in the same save wins.
Changing a job's unit later keeps historical records on the unit they were worked under. Only the job's future, unworked shifts move to the new unit: scheduled start in the future, no actual start time, blank approval status and not yet interpreted. The Job trigger starts SbuRestampBatch for this automatically. Working patterns, booking requests and expenses of the job keep their unit.
In SBU mode the runner shows an SBU picker (default: All SBUs). A run limited to a unit interprets only shifts whose b3s__SBU__c is that unit, stores the unit on the run (Pay_Bill_Run__c.SBU__c, shown next to the period in the run list) and reverses over the same unit. Re-run keeps the original run's unit. Pick one unit per run; start one run per unit for a multi-unit payroll.
On an App or Home page in SBU mode the bulk run offers an SBUs checkbox group (none ticked = every unit) and the invoice list shows an SBU column. A bulk run processes each client one unit at a time: only that unit's uninvoiced lines are invoiced, only that unit's un-numbered drafts are replaced, and the configuration is resolved per unit.
On an Account page, Generate invoices every unit of the account with the selected configuration; the SBU split key still produces one invoice per unit.
In SBU mode the Studio header search always offers an SBU filter (shiftPath and expensePath b3s__SBU__c), also on a custom Shift Management Studio configuration that does not list it. It starts pre-selected with the user's own SBU assignments; remove the pills to see every unit. The shift table shows the unit under Job / Site. To add the filter explicitly (for example with another label), add it to the configuration JSON:
"headerFilters": [
{ "key": "sbu", "label": "Business unit", "shiftPath": "b3s__SBU__c", "expensePath": "b3s__SBU__c" }
]
Two clause tokens are available in loader filterRecordsBy and schedulable selectionClause (see Loaders):
| Token | Resolves to |
|---|---|
:sbuIds |
The running user's units from their User SBU Assignments, as ('id1','id2'). Unrestricted when SBU mode is off or the user has no assignment: every active SBU plus blank, so b3s__SBU__c IN :sbuIds is always safe. |
:userSbuId |
The user's primary unit as a quoted Id, or '' when none. |
{ "name": "unitShifts", "objectName": "b3s__Shift__c",
"filterRecordsBy": "b3s__SBU__c IN :sbuIds AND b3s__Status__c != 'Cancelled'" }
Portal guests and community users have no User assignments, so the token does not narrow their results. Portal sessions are scoped by access profiles and :accountIds. Portals never expose the unit structure: b3s__SBU__c and b3s__SBU_Assignment__c are not available to portal sessions.
The sample compliance rule Scheduler: SBU Match (b3s__Scheduling_Compliance_Rule.WFM_Scheduler_SBU_Match, unpackaged sample) warns, without blocking, when a worker is not assigned to the shift's unit. Cross-unit redeployment stays possible but visible. It needs a scheduler loader named sbuAssignments and b3s__SBU__c among the shift schedulable's field paths:
{ "name": "sbuAssignments", "objectName": "b3s__SBU_Assignment__c",
"fieldToLoad": "b3s__SBU__c, b3s__Contact__c", "groupRecordsBy": "b3s__Contact__c",
"filterRecordsBy": "b3s__Contact__c != null" }
With SBU mode on and the WFM custom setting field SBU Sharing Enabled (b3s__Scheduler__c.b3s__SBU_Sharing_Enabled__c, off by default) ticked, the package maintains sharing so that users of a unit can be limited to that unit's records. The sharing only restricts anything once you set the organisation-wide default (OWD) of the objects to Private; until then every user still sees every record, as before.
Leave SBU Sharing Enabled unticked when you need SBUs only for tagging, filters, number series, legal entities and invoicing, with no change to who sees what. No groups, group members or share rows are written then, and the back-fill batch only stamps units and creates primary assignments. Ticking it later and running the back-fill batch writes the groups and shares for existing records. Unticking it stops further share maintenance but does not remove rows already written; delete the SBU groups (Setup > Public Groups, names starting SBU_) to remove their access.
| Record | Shared with | How |
|---|---|---|
| Shift, Job, Expense | The group of the record's SBU__c |
Share row with the Apex sharing reason SBU, Read/Write. Moves when the unit changes. Kept on owner change. |
| Site | The groups of every unit the site's account is assigned to | Share rows with the SBU reason. Follows the account's SBU Assignments and a change of the site's account. |
| Booking Request | The group of its SBU__c |
Same as Shift, but only once the object has a sharing table (see the admin steps). |
| Account | The groups of every unit in its SBU Assignments | Manual AccountShare rows, Read/Write on the account, no opportunity or case access. Written only while the Account OWD is Private or Public Read Only. Re-created after an owner change, because Salesforce deletes manual shares when the owner changes. |
| Contact | The groups of every unit in its SBU Assignments | Manual ContactShare rows, same rules as Account. Written only while the Contact OWD is Private or Public Read Only, never while it is Controlled by Parent. The package does not depend on Contact sharing, so it installs in orgs where Contact is Controlled by Parent. |
| Working Pattern, Cost Center | Controlled by parent: nothing to maintain. |
Each unit has a public group named SBU_<SBU record Id> (label "SBU" + the unit name), created when the SBU is saved in SBU mode and stored in Group_Id__c. Its members are the users of the unit's User SBU Assignments. Adding or removing a User assignment updates the membership a few seconds later (an asynchronous job, because group membership is setup data). A user with several assignments is in several groups and sees the union.
Only rows granted to SBU groups are ever changed. Your own manual shares and sharing rules are untouched.
Role hierarchy still applies: managers above a group member see what the member sees. Profiles and permission sets with View All or Modify All on an object still see everything on it.
Portal and kiosk sessions are unchanged. Portal sessions are scoped by access profiles and :accountIds. The SBU and SBU Assignment objects stay hidden from portal sessions.
The package cannot change OWD on install or upgrade. An org that never changes it keeps today's visibility.
Run from Setup > Developer Console > Execute Anonymous:
Database.executeBatch(new b3s.SbuBackfillBatch(), 200);
It does nothing while SBU mode is off. Otherwise it chains one run per object (Job, Account, Contact, Site, Shift, Working Pattern, Booking Request, Expense, Invoice, Pay/Bill Staging) and:
Interpreted shifts, approved expenses and numbered invoices are stamped too: the batch writes only the unit, bypassing the payroll and invoice locks. It is safe to run again.
SbuRestampBatch re-stamps a job's future unworked shifts after the job's unit changes (see How a record gets its unit). The Job trigger starts it. A job changed from a batch or scheduled job does not start it; run it by hand with the job Ids:
Database.executeBatch(new b3s.SbuRestampBatch(new Set<Id>{ 'a0X...' }), 200);
Invoice numbers come from the invoice's SBU (blank = the default SBU):
Invoice_Prefix__c + Last_Invoice_Number__c.Self_Bill_Prefix__c + Self_Bill_Last_Number__c. A self-bill numbers from the unit receiving the supply, so self-bills of every vendor share one series per unit.Issuing locks the units involved and increments the counter, so concurrent issues never reuse a number. With one unit this gives one global series per document kind; with several units each entity has its own.
When the unit has no prefix for the kind, the legacy series applies: the configuration's Invoice_Prefix__c / Last_Invoice_Number__c for client invoices, the vendor account's Self_Bill_Prefix__c / Self_Bill_Last_Number__c for self-bills. These fields remain available for intentional per-configuration or per-vendor numbering. Leave the unit's prefix blank for the relevant kind to use them; a populated unit prefix takes precedence over both the fallback prefix and counter. Client and self-bill choices are independent. Only the selected counter advances, so review the destination counter before switching series. See Issuing and numbering for setup and examples.
On every install and upgrade, when no SBU exists, a default SBU is created from Company Information (name, address) with code DEFAULT:
Last_Invoice_Number__c across all invoice configurations, with the prefix of the default configuration (else the first configuration with a prefix), so numbering continues without a collision;Self_Bill_Last_Number__c, and its self-bill prefix is left blank, so vendors keep their own self-bill series until finance sets a prefix on the SBU.The step never fails the install. If the org already has SBUs but none is the default, nothing is created: tick Default on one of them.
After upgrading, review the default SBU: fill in the legal name, tax and company registration numbers, bank details and logo, and set Number_Padding__c if your numbers should be fixed-width. If several configurations used different prefixes, decide which prefix the unit series should carry.
In SBU mode the unit joins the implicit split keys (kind, bill-to, currency, category and SBU), so each invoice belongs to one unit and therefore one number series and one letterhead. The invoice's SBU__c is stamped at generate. Credit notes carry the unit of the invoice they credit. With the mode off, every invoice is stamped with the default SBU.
Turning SBU mode on changes the split key of new drafts. With the Amend Existing correction mode, new lines no longer join invoices issued before the switch; they go on new invoices.
An invoice configuration can be scoped to a unit with SBU__c. When a bulk run invoices a client's lines of one unit, the configuration is resolved in this order:
Is_Default__c, no Account).The shipped Default template (InvoicePdf page) prints the SBU as "this organisation" when the invoice has a unit:
Without a unit, the org's Company Information is used, as before. Custom templates can read the same properties from the InvoicePdfController (supplier, customer, logoUrl, bankDetails).
InvoiceTaxRequest carries sbu (name, legal name, tax registration number, country, province/state) so a custom InvoiceTaxPlugin can apply the issuing entity's own registration and rates. The default plugin ignores it.
Due date = issue date + the configuration's Payment_Terms_Days__c, else the SBU's Payment_Terms_Days__c, else 0.
Every pay staging line carries the shift's unit, so a payroll export can group by it. Separate legal entities run separate payrolls; the recommended grouping for a payroll export is the worker's primary unit (the employer, Contact.SBU__c) with the shift unit on each line for intercompany recharge.
:sbuIds default to their units.Bank_Details__c field-level security as needed.