SharePoint Connector Documentation
Index

Auto-Upload Configuration

The SharePoint Connector can automatically upload documents to SharePoint when posting sales and purchase documents. This page explains how to configure and use auto-upload.

Auto-Upload Overview

What is Auto-Upload?

Auto-upload automatically generates and saves PDF copies of documents when they are posted:

  • Post a sales invoice → PDF saved to customer's SharePoint folder
  • Post a purchase invoice → PDF saved to vendor's SharePoint folder
  • No manual action required

Supported Documents

Document Type Auto-Upload Available
Sales Invoices Yes
Sales Credit Memos Yes
Sales Shipments Yes (additional toggle — requires Auto-Upload Sales Documents)
Purchase Invoices Yes
Purchase Credit Memos Yes

Enabling Auto-Upload

Configuration Steps

  1. Open SharePoint Setup
  2. Locate the auto-upload settings section
  3. Enable the document types you want

Available Settings

Setting Description
Auto-Upload Sales Documents Upload sales invoices and sales credit memos
Auto-Upload Sales Shipments Upload sales shipments (additional toggle — only works when Auto-Upload Sales Documents is also enabled)
Auto-Upload Purchase Documents Upload purchase invoices and purchase credit memos

Process Mode

The auto-upload process subscribes to the OnAfterFinalizePosting events of the Sales-Post and Purch.-Post codeunits. When triggered in background mode, it uses Session.StartSession to run the upload in a background session. If the background session fails, sales documents fall back to running in the foreground; purchase documents do not.

Mode Description Best For
Background Uses a background session via Session.StartSession Production use, doesn't block posting
Foreground Immediate upload Testing, small volume

Prerequisites

Table Mappings Required

Auto-upload requires a table mapping on the posted document table itself — a mapping on Customer or Vendor alone is not enough, because the folder lookup runs on the posted table. Typically the posted table gets an Inherited Dynamic mapping pointing at the Customer or Vendor:

Document Required Mapping
Sales Invoices Sales Invoice Header (posted) — typically Inherited Dynamic from Customer
Sales Credit Memos Sales Cr.Memo Header (posted) — typically Inherited Dynamic from Customer
Purchase Invoices Purch. Inv. Header (posted) — typically Inherited Dynamic from Vendor

Report Selections

The connector uses Report Selections to determine which report to generate:

  1. Go to Report Selections - Sales or Report Selections - Purchase
  2. Verify reports are configured for:
    • Invoice
    • Credit Memo
    • Shipment

Folder Destination

Configure where auto-uploaded documents go:

  • Uses the posted document's mapped folder
  • Or inherits from parent (Customer/Vendor)
  • Can use auto-upload subfolder (see below)

Auto-Upload Subfolder

Configuring Auto-Upload Subfolder

Route auto-uploaded documents to a specific subfolder:

  1. Go to Auto-Create Subfolders
  2. Find or create the subfolder entry
  3. Enable Auto Upload Folder = Yes
Field Value
Table No. 112 (Sales Invoice Header)
Subfolder Name Invoices
Auto Upload Folder Yes

Note: The Auto-Create Subfolder entry must be on the posted document table (for example, 112 Sales Invoice Header) — not on the Customer or Vendor table.

Result

Posted invoices automatically go to: /Customers/Contoso Ltd/Invoices/INV-001.pdf

How Auto-Upload Works

Posting Flow

  1. User posts a sales/purchase document
  2. Posting routine completes
  3. Auto-upload is triggered
  4. Report is generated as PDF
  5. PDF is uploaded to SharePoint
  6. Metadata is populated (if configured)

Background Processing

When using background mode:

  1. Posting completes and the OnAfterFinalizePosting event fires
  2. A background session is started via Session.StartSession
  3. The background session generates the PDF using Report Selections and uploads it to SharePoint
  4. For sales documents, if the background session fails, the upload falls back to running in the foreground (purchase documents have no fallback)
  5. User can continue working

Foreground Processing

When using foreground mode:

  1. Posting pauses
  2. Document is uploaded
  3. User may see progress
  4. Posting completes when upload finishes

File Naming

Automatic Naming

Auto-uploaded files are named based on:

  • Document number
  • Document type
  • Configuration settings

Example Names

The filename is the Report Caption followed by the document number, with a .pdf extension (see SP.SanitizeNameNoDot(Reports."Report Caption" + ' ' + DocNo + '.pdf') in Background Report Handling EFQ):

Document Example Filename
Sales Invoice Sales - Invoice 103001.pdf
Sales Credit Memo Sales - Credit Memo 104001.pdf
Purchase Invoice Purchase - Invoice 106001.pdf

The exact Report Caption comes from the Report Selections-configured report, so the prefix matches whatever report the customer uses for the document type.

Monitoring Auto-Upload

Verification

After posting, verify upload:

  1. Open the posted document
  2. Check the SharePoint FactBox
  3. PDF should appear in the file list

Error Handling

If auto-upload fails:

  • For sales documents: If the background session fails, the upload falls back to foreground
  • For purchase documents: There is no automatic fallback; the upload is skipped
  • Document is still posted regardless of upload outcome
  • Debug mode always forces foreground processing
  • You can manually upload the document if needed

Configuration Examples

Sales Documents Only

Setting Value
Auto-Upload Sales Documents Yes
Auto-Upload Sales Shipments No
Auto-Upload Purchase Documents No

All Documents, Immediate

Setting Value
Auto-Upload Sales Documents Yes
Auto-Upload Sales Shipments Yes
Auto-Upload Purchase Documents Yes

Troubleshooting Auto-Upload

Document Not Appearing

Check Resolution
Auto-upload enabled? Enable in SharePoint Setup
Table mapping exists? Create mapping for document table
Report selection set? Configure report selections

Upload Errors

Error Solution
Permission denied Check SharePoint permissions
Folder not found Verify mapping and folder path
Report error Check Report Selections configuration
Token expired Re-authenticate in SharePoint Setup

Background Session Failing

For sales documents, if the background session fails, auto-upload automatically falls back to foreground processing. For purchase documents, there is no automatic fallback — if the background session fails, the upload is silently skipped. If uploads continue to fail:

  1. Review the error message
  2. Fix the underlying issue (permissions, folder mapping, etc.)
  3. Manually upload the document or re-post if needed

Best Practices

Production Recommendations

Practice Reason
Use Background mode Doesn't slow down posting
Configure subfolders Keep documents organized
Test in sandbox first Verify configuration

Performance Considerations

  • Background mode scales better
  • Large documents take longer
  • High volume may queue up