Requested Documents

Release Notes — Requested Document Counts on Document Assignment

What's new

The Document Assignment (b3o__Document_Assignment__c) now shows live counts of the documents requested from the contact, so admins and flows can see onboarding progress at a glance without opening the portal.

New fields on Document Assignment

Field Type Meaning
Requested Documents (b3o__Requested_Documents__c) Number How many documents of the pack are currently visible/required from the contact (after evaluating each document's conditional rendering rule).
Submitted Documents (b3o__Submitted_Documents__c) Number Requested documents with at least one submission.
Completed Documents (b3o__Completed_Documents__c) Number Requested documents whose latest submission is Approved and not expired.
Outstanding Documents (b3o__Outstanding_Documents__c) Formula (Number) Requested - Submitted.
All Documents Submitted (b3o__All_Documents_Submitted__c) Formula (Checkbox) True when at least one document is requested and all are submitted.
All Documents Completed (b3o__All_Documents_Completed__c) Formula (Checkbox) True when at least one document is requested and all are completed.

The checkbox formulas are ideal entry criteria for flows and reports (e.g. "notify recruiter when all documents are completed").

How it works

Data migration switch

b3o__Onboarding_Trigger_Control__c.b3o__Disable_Requested_Documents_Trigger__c (hierarchy custom setting) bypasses the automatic creation/sync triggers during data loads. Run the backfill batch afterwards (below). The count rollup itself is never bypassed.


Post-install: backfill existing Document Assignments

Document Assignments created before this version have no Requested Documents and their counts are blank. Backfill them once after installing/upgrading:

  1. Open Developer Console → Debug → Open Execute Anonymous Window (or use sf apex run).
  2. Run:
Database.executeBatch(new b3o.RequestedDocsRecalcBatch(
    'SELECT Id FROM b3o__Document_Assignment__c'
), 5);

Notes:

// Only assignments for contacts still onboarding
Database.executeBatch(new b3o.RequestedDocsRecalcBatch(
    'SELECT Id FROM Contact WHERE Onboarding_Status__c = \'In Progress\''
), 5);

Recalculating on demand (Flow / Apex)

Because document visibility can depend on data outside the pack (contact fields, certificate expiry dates, etc.), you decide when to recalculate. The package exposes an invocable action:

Action: 3B Recalculate Requested Documents (category: 3B Onboarding)

Input: Assignment Ids — a list of b3o__Document_Assignment__c record Ids.

From Flow

  1. In Flow Builder, add an Action element and search for 3B Recalculate Requested Documents.
  2. Pass the Document Assignment Id(s) into Assignment Ids (a text collection of record Ids, or a single record Id resource).
  3. Typical wiring:
    • Record-Triggered Flow on Contact — when a field used in rendering rules changes, pass the Ids of the contact's Document Assignments (Get Records on b3o__Document_Assignment__c where b3o__Contact__c = the contact).
    • Screen Flow / quick action on Document Assignment — pass recordId for a manual "Recalculate" button.

The action returns immediately; the recalculation runs asynchronously in the background (it self-chains for large packs). Counts update within moments.

From Apex

b3o.RequestedDocumentsHelper.recalculate(new Set<Id>{ assignmentId });

Safe to call from triggers and from already-async contexts (falls back to inline processing when no queueable slots remain).

When to trigger a recalculation

All recalculation paths are idempotent — running them twice is harmless.