Posting Flow Behavior
This page explains how the auto-upload process integrates with the standard Business Central posting flow for sales and purchase documents.
Posting Flow Overview
Standard BC Posting
Without the connector:
- User clicks Post
- Document is validated
- Ledger entries created
- Posted document created
- Original document archived/deleted
- Process complete
With Auto-Upload
With the connector enabled:
- User clicks Post
- Document is validated
- Ledger entries created
- Posted document created
- OnAfterFinalizePosting event fires on Sales-Post or Purch.-Post codeunit
- Auto-upload event subscriber starts a background session (via Session.StartSession)
- Background session generates PDF using Report Selections and uploads to SharePoint
- Original document archived/deleted
- Process complete
Note: For sales documents, if the background session fails, the upload falls back to running in the foreground. For purchase documents, there is no automatic fallback. Debug mode always forces foreground processing.
Background vs Foreground
Background Processing (Recommended)
When Auto Upload Process = Background:
Posting Timeline:
[Post] → [Validation] → [Create Posted Doc] → [OnAfterFinalizePosting] → [Complete] → User continues
↓
[Background session via StartSession]
↓
[Generate PDF → Upload to SharePoint]
Characteristics:
- User isn't blocked
- Upload happens asynchronously via a background session
- For sales, if the background session fails, falls back to foreground
- For purchase, no automatic fallback
- Better for high volume
- Slight delay before document appears in SharePoint
Foreground Processing
When Auto Upload Process = Foreground:
Posting Timeline:
[Post] → [Validation] → [Create Posted Doc] → [Generate PDF] → [Upload] → [Complete]
↓
User can continue
Characteristics:
- User waits for upload
- Immediate confirmation
- Better for low volume
- Can slow down posting
Document Generation
Report Selection
The system uses Report Selections to determine which report to generate:
- Looks up Report Selection for the document type
- Finds the assigned report
- Generates PDF using that report
- Custom layouts are used if configured
Report Selection Configuration
| Usage | Document Type |
|---|---|
| Sales - Invoice | Posted Sales Invoice |
| Sales - Credit Memo | Posted Sales Credit Memo |
| Sales - Shipment | Posted Sales Shipment |
| Purchases - Invoice | Posted Purchase Invoice |
| Purchases - Credit Memo | Posted Purchase Credit Memo |
Note: Purchase Receipts are not auto-uploaded.
Custom Report Layouts
If you use custom report layouts:
- Auto-upload uses your custom layout
- PDF reflects your customizations
- Same as if printed manually
Folder Destination Logic
Determining the Folder
The connector determines where to upload:
- Check if posted document table has mapping
- If mapping is "Inherited Dynamic", find parent
- Navigate to parent's folder
- Check for auto-upload subfolder
- Upload to final destination
Example Flow for Sales Invoice
- Posted Sales Invoice 103001 created
- Check mapping: Sales Invoice Header → Inherited from Customer
- Find customer: Contoso Ltd
- Get customer's SharePoint folder:
/Customers/Contoso Ltd - Check auto-upload subfolder:
Invoices - Final path:
/Customers/Contoso Ltd/Invoices/ - Upload PDF
Metadata Population
During Auto-Upload
If metadata columns are configured:
- PDF is uploaded
- Metadata mapping is checked
- BC field values are read
- SharePoint columns are populated
Available Metadata
From the posted document:
| Field | Example |
|---|---|
| Document No. | 103001 |
| Posting Date | 2024-01-15 |
| Amount | 1,500.00 |
| Customer/Vendor | Contoso Ltd |
Error Handling
What Happens on Error
If auto-upload fails:
| Stage | Behavior |
|---|---|
| Posting | Continues, not affected — posting always succeeds |
| Posted document | Still created |
| Background failure | Fails silently — nothing is logged |
| Foreground failure | An error message is shown to the user |
| User impact | May not notice (background) |
Recovery Options
| Option | How |
|---|---|
| Automatic fallback (Sales only) | If the background session fails, upload runs in the foreground |
| Manual upload | Generate PDF, upload manually |
| Fix and retry | Address error, re-post or manually upload |
Common Errors
| Error | Cause | Resolution |
|---|---|---|
| Folder not found | Missing mapping | Create table mapping |
| Permission denied | SP permissions | Grant write access |
| Report error | Report issue | Check Report Selections |
| Network timeout | Connectivity | Retry later |
Performance Considerations
High Volume Posting
For posting many documents:
| Recommendation | Reason |
|---|---|
| Use Background | Don't slow down posting |
| Consider batch times | Upload during low activity |
Document Size
Large documents:
- Take longer to generate
- Take longer to upload
- May timeout in foreground mode
- Background mode handles better
User Experience
Foreground Mode
User experience:
- Clicks Post
- Sees posting progress
- May see upload progress
- Posting completes
- Can verify in FactBox immediately
Background Mode
User experience:
- Clicks Post
- Posting completes quickly
- Continues working
- Checks FactBox later
- PDF appears eventually
Notifications
Currently:
- No automatic notification when upload completes
- Check FactBox to verify
Integration with Other Features
Document Templates
Auto-upload uses different mechanism than templates:
- Auto-upload: Triggered on posting
- Templates: Triggered by user action
E-Signing
To send auto-uploaded document for signing:
- Document is auto-uploaded
- User opens posted document
- Selects file in FactBox
- Initiates e-signing
Customization
Extending Auto-Upload
For custom scenarios:
- Event subscribers available
- Can add custom logic
- Can modify file naming
- Can add additional metadata
Contact a partner for custom development needs.