Push Documents from Business Central to SFTP via Power Automate
This post demonstrates how to push a Sales Invoice PDF from Business Central to an SFTP site whenever an invoice is posted, using a staging table, a custom codeunit that subscribes to posting events, and a Power Automate workflow to handle the file transfer and status updates.

post Aardvark Labs
"For this to work neatly and allow for retries and other advanced management tools we are going to start with a staging table."
Key points
- A staging table (ARD_PAFTPSend) stores invoice files as blobs and tracks whether they have been sent to SFTP
- The codeunit subscribes to the OnAfterPostSalesDoc event, generates the invoice as a PDF, and fires a business event when ready
- Report parameters are extracted as XML and parameterized to enable dynamic report generation with the invoice number
- Power Automate listens for the business event, retrieves the file and metadata from the staging table, uploads to SFTP, and updates the staging record
- The pattern supports retries, failed transfers can be retried by re-firing the business event, and alternative endpoints like SharePoint or network storage can replace SFTP
Quotes
- “For this to work neatly and allow for retries and other advanced management tools we are going to start with a staging table.” (Explains the architectural choice to use an intermediate table, providing resilience and visibility into the transfer process rather than direct posting.)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- table “ARD_PAFTPSend”
- page “ARD_PAFileStaging”
- api “ARD_PAFileStagingAPI”
- codeunit “ARD_PAFTPSend”
- other “ARD_ReportLayouts”
Not found in BC28-30: table “ARD_PAFTPSend”, page “ARD_PAFileStaging”, codeunit “ARD_PAFTPSend”.
Context
- Features: staging table for file uploads, business events, Power Automate integration, API pages, report parameter extraction, blob field storage, file status tracking, retry capability
Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.