Auto-Post Approved Invoices
When the Auto-Post Approved Invoices setting is enabled, purchase documents that go through the eMessaging approval workflow are automatically posted the moment the final approval is granted and the document is released. This eliminates the manual posting step after approval.
Setup
Location: Purchases & Payables Setup → eMessaging tab
Field: Auto-Post Approved Invoices (RSMSTA Auto-Post Approved Inv.)
This is a simple Boolean toggle with no additional configuration required. It works alongside the existing approval workflow settings — the Centara Approval Workflow must be active (either standard approvers or Workflow User Groups) for this setting to have any effect.
How it triggers
The auto-posting logic runs inside the OnAfterPerformManualCheckAndRelease event subscriber on the Release Purchase Document codeunit. This means it fires at the moment a document transitions to Released status — whether that happens via the standard approval workflow completing, or any other release action.
Two conditions must both be true for auto-posting to run:
- The document is Released —
PurchaseHeader.Status = Released - An approval was requested for this document AND Auto-Post Approved Invoices is enabled
The second condition is evaluated by RSMSTAApprovalWasRequested() on the Purchase Header, which returns true if any of the following apply:
- The standard approval workflow is enabled AND the document has an Original Approval User assigned
- “Require Approval for Everything” is enabled (all documents go through approval)
- The User Group approval workflow is enabled AND the document has a Workflow User Group assigned
This means the auto-post will not fire if a document is released manually without going through an approval workflow.
What happens when it posts
When both conditions are met, the system:
- Issues a
Commit()to save any pending changes before attempting the post - Sets the posting flags on the document:
- Purchase Orders → Receive = true, Invoice = true (receive and invoice in one step)
- Purchase Invoices / Credit Memos / Return Orders → Ship = true, Invoice = true
- Runs Codeunit Purch.-Post — the standard Business Central purchase posting codeunit
- Updates the e-document status on the linked Integration Peppol Header:
- Success → status set to Processed
- Failure → status set to Error, and the last error text is recorded on the header for review
If auto-posting is not triggered (because the document was released without an approval, or the setting is off), the document status is instead updated to Ready for Posting, leaving it available for manual posting as normal.
Document status flow
flowchart TD
A["Inbound document received"] --> B["Sent to approval\n(Pending Approval)"]
B --> C["Approved → Document Released"]
C --> D{"Auto-Post Approved\nInvoices enabled?"}
D -- Yes --> E["Purch.-Post runs automatically"]
E --> F{"Post successful?"}
F -- Yes --> G["Status: Processed"]
F -- No --> H["Status: Error\n(error text recorded)"]
D -- No --> I["Status: Ready for Posting\n(manual post required)"]
Important behaviours
- All document types are supported. Purchase Orders, Invoices, Credit Memos, and Return Orders are all handled. The posting flag differs (Receive vs. Ship) but the outcome is the same.
- Standard BC posting logic is used. No custom posting code is involved — Purch.-Post is the same codeunit BC uses everywhere, so all standard validations, VAT, dimensions, and G/L postings apply normally.
- Errors are non-blocking. If posting fails, the job does not throw an error to the user. The failure is silently captured and recorded on the Integration Peppol Header as an error status, so it can be reviewed and actioned from the inbound documents page.
- A Commit is issued before posting. This ensures any prior changes (e.g., approval status updates) are saved before the posting transaction begins, which is necessary since posting runs in its own transaction scope.
- No effect on documents released without an approval. If a user manually releases a document that was never sent for approval,
RSMSTAApprovalWasRequested()returnsfalseand the normal “Ready for Posting” path is taken.
Two posting paths
There are two distinct mechanisms that can auto-post a purchase document. They work differently and serve different scenarios.
Path 1 — Event-driven (synchronous)
Codeunit: 10058614 RSMSTA Four Eyes Approval
This is the primary path. It runs synchronously and immediately the moment a document is approved and released. There is no job queue involved and nothing to schedule — it fires automatically via an event subscriber on Business Central’s standard Release Purchase Document codeunit (OnAfterPerformManualCheckAndRelease).
When it fires: The instant the final approver approves the document and it transitions to Released status.
No job queue setup is needed for this path.
Path 2 — Background job (batch)
Codeunit: 10058611 RSMSTA Post Autoprocessed Docs
This is the background safety net. It runs on a schedule and looks for any Purchase Orders that have been autoprocessed (RSMSTA Autoprocessed = true) and are in Released status with an approval request on record — and posts them if they haven’t been posted yet.
This path handles cases where Path 1 may not have fired (for example, a document was released through a path that didn’t trigger the synchronous event, or the synchronous post failed silently and needs a retry sweep).
Setting up the job queue
The job queue entry for this codeunit is created automatically when you enable “Enable Auto-Process Invoices” in Purchases & Payables Setup. You do not need to create it manually. When the setting is turned on the entry is set to Ready; when turned off it is set to On Hold.
If you ever need to create or verify it manually:
| Field | Value |
|---|---|
| Object Type to Run | Codeunit |
| Object ID to Run | 10058611 |
| Description | Run Post Autoprocessed Docs codeunit |
| Job Queue Category Code | RSMSTA |
| No. of Minutes Between Runs | 5 (default) |
Navigate to Job Queue Entries → find entry for codeunit 10058611 → verify Status is Ready.
Recommended execution frequency
The default is every 5 minutes, which is appropriate for most environments.
| Scenario | Recommended interval |
|---|---|
| High volume / time-sensitive (100+ invoices/day) | 2–5 minutes |
| Standard AP workload | 5–10 minutes |
| Low volume (fewer than 20–30 invoices/day) | 15–30 minutes |
The synchronous path (Path 1) handles the immediate case, so this job is a backstop.
Companion job queue
There is also a companion job queue for the document intake side:
| Field | Value |
|---|---|
| Object ID to Run | 10058628 |
| Description | Run auto process PO codeunit |
| No. of Minutes Between Runs | 5 (default) |
This codeunit (RSMSTA AutoProcessJobQueue) picks up newly arrived inbound documents (status New or In Matching) and runs the matching and autoprocess logic on them. It should run at the same frequency as 10058611 — they are two halves of the same pipeline: one processes incoming documents into purchase documents, the other posts those purchase documents once approved.
Summary
| Path 1 (Event-Driven) | Path 2 (Background Job) | |
|---|---|---|
| Codeunit | 10058614 | 10058611 |
| Trigger | Immediate on approval/release | Scheduled job queue |
| Job Queue Needed? | No | Yes (auto-created) |
| Default Interval | N/A | Every 5 minutes |
| Scope | All approved document types | Purchase Orders only |
| Purpose | Immediate post on approval | Backstop for missed/failed posts |
Related pages
- Posting Documents — manual posting and external attachment storage
- Auto Processing — the full auto-processing pipeline
- Approval Setup — approval workflow configuration
- Purchases & Payables Setup — the setup page where this setting lives