🔧 Method Signature
global static void automateProcess(String parentRecordId, String applicationName, Map<String, List<Id>> mapSelectedDocs)
📌 Purpose
The automateProcess method is a global automation entry point in the Document Insights application that prepares and initiates PDF document conversion through Moneythumb or Ocrolus, based on the selected documents.
It validates the selected documents, constructs a standardized request payload, and calls the internal PDF Insight processing service to perform document parsing and analysis.
🧾 Parameters
|
Parameter |
Description |
|---|---|
|
|
(String) – Salesforce ID of the parent record (e.g., Loan, Opportunity, Application) under which the documents are being processed. |
|
|
(String) – Name of the invoking application. Can be left empty as well. |
|
|
(Map<String, List<Id>>) – A map of selected documents:
|
⚙️ Supported Document Types per Vendor -
-
MoneyThumb - Bank Statements,Credit Card Statements,Plaid JSON
-
Ocrolus - Bank Statements, Credit Card Statements, Plaid JSON, Driving License, Passport, Passport Card, SSN, PayStubs, SSA-1099, IRS Form 1040 (2022), IRS Form W-2
🔁 Automation Workflow
1. Retrieve Valid Document Types
-
Fetches the list of allowed document types from custom metadata or configuration via
ConfigurationService.getValidPDFType().
2. Input Validation
-
Validates:
-
parentRecordIdis not blank. -
mapSelectedDocsis not null or empty. -
Each document type prefix (before
::) is among the valid types (e.g.,Bank,CCard,Plaid).
-
-
If any validation fails, it throws an
InvalidParametersExceptionwith a detailed error message.
3. Document Preparation
-
Iterates through the map entries.
-
For each document, parses:
-
DocumentType– extracted from the key before::. -
Source– extracted from the key after::. -
ContentDocumentId– each file/document Id in the list.
-
-
Constructs a list of
SelectedDocumentWrapperobjects with this information.
4. Service Invocation
-
Serializes the wrapper list into JSON.
-
Invokes
PDFInsightRequestController.callPDFInsightService()with:-
The parent record Id
-
The JSON payload of document metadata
-
✅ Expected Outcome
-
Valid documents are queued for processing via the Document Insights pipeline.
-
The target PDF processing service (Moneythumb or Ocrolus) is called internally based on the source metadata.
-
Status tracking and further processing are handled in downstream logic (outside this method).
⚠️ Error Handling
|
Scenario |
Action |
|---|---|
|
|
Adds error message: "Parent Record Id cannot be null." |
|
|
Adds error message: "At least one document is required to start the Document Convert Process." |
|
Invalid |
Adds error message: "Invalid Document Type. Valid values: Bank, CCard, Plaid." |
|
If any of the above fail |
Throws |
🧪 Example Input
Map<String, List<Id>> selectedDocs = new Map<String, List<Id>>{'Bank::Moneythumb' => new List<Id>{'069XX0000001abc', '069XX0000001xyz'}};
AutomatePDFInsightProcess.automateProcess('006XX000000abcd', '', selectedDocs);
🗂️ Supporting Classes & Services
|
Component |
Description |
|---|---|
|
|
Returns a delimited string of valid document types (e.g., |
|
|
Wrapper class with fields: |
|
|
Performs the actual callout/logic to submit documents to Moneythumb/Ocrolus. |
|
|
Custom exception thrown on invalid inputs. |