SharePoint Connector Documentation
Index

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:

  1. User clicks Post
  2. Document is validated
  3. Ledger entries created
  4. Posted document created
  5. Original document archived/deleted
  6. Process complete

With Auto-Upload

With the connector enabled:

  1. User clicks Post
  2. Document is validated
  3. Ledger entries created
  4. Posted document created
  5. OnAfterFinalizePosting event fires on Sales-Post or Purch.-Post codeunit
  6. Auto-upload event subscriber starts a background session (via Session.StartSession)
  7. Background session generates PDF using Report Selections and uploads to SharePoint
  8. Original document archived/deleted
  9. 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

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:

  1. Looks up Report Selection for the document type
  2. Finds the assigned report
  3. Generates PDF using that report
  4. 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:

  1. Check if posted document table has mapping
  2. If mapping is "Inherited Dynamic", find parent
  3. Navigate to parent's folder
  4. Check for auto-upload subfolder
  5. Upload to final destination

Example Flow for Sales Invoice

  1. Posted Sales Invoice 103001 created
  2. Check mapping: Sales Invoice Header → Inherited from Customer
  3. Find customer: Contoso Ltd
  4. Get customer's SharePoint folder: /Customers/Contoso Ltd
  5. Check auto-upload subfolder: Invoices
  6. Final path: /Customers/Contoso Ltd/Invoices/
  7. Upload PDF

Metadata Population

During Auto-Upload

If metadata columns are configured:

  1. PDF is uploaded
  2. Metadata mapping is checked
  3. BC field values are read
  4. 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:

  1. Clicks Post
  2. Sees posting progress
  3. May see upload progress
  4. Posting completes
  5. Can verify in FactBox immediately

Background Mode

User experience:

  1. Clicks Post
  2. Posting completes quickly
  3. Continues working
  4. Checks FactBox later
  5. 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:

  1. Document is auto-uploaded
  2. User opens posted document
  3. Selects file in FactBox
  4. 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.