Document Sync Demo
Demo flow that watches a source SharePoint document library and replicates new and modified files to a destination location (OneDrive folder or another SharePoint library), preserving metadata and handling conflict cases.
Overview
Watches a configured SharePoint document library and replicates new files to a OneDrive for Business folder, preserving folder structure and enforcing a maximum file size. On success it sends a confirmation email; on size overrun it sends a too-large notice; any unexpected error drops into a Scope-level error handler that emails the operator.
**Flow ID:** 541c9567-852b-f111-8341-6045bd0052fe • **State:** Off (demo)
Use Case
Teams often need a copy of SharePoint library content mirrored into OneDrive for offline editing, sharing with external partners, or for an Office app that integrates more cleanly with OneDrive. This flow automates the copy, fails loudly via email, and keeps an audit trail in Sent Items.
**Key Benefits:** real-time replication; configurable size guard; error-handling Scope; success/too-large/failure notifications; all values driven by env vars.
Flow Architecture
Trigger: **When a File Is Created in Document Library** (SharePoint). 1. Initialize 6 variables (site URL, library, OneDrive folder, notify email, max file size MB) 2. **Check File Size Within Limit** (If) - True: Get File Content → Build OneDrive Path → Create File in OneDrive → Send Success Email - False: Send File Too Large Email 3. **Error Handling Scope** (runs on failure of #2): Send Sync Failure Email
Environment Variables
| Variable | Schema Name | Type | Default | Purpose |
|---|---|---|---|---|
| SharePoint Site URL | flowlibs_SharePointSiteURL | String | (none) | Absolute URL of the source SharePoint site |
| SharePoint Doc Sync Library ID | flowlibs_SharePointDocSyncLibraryID | String | (none) | GUID of the source document library to watch |
| OneDrive Sync Folder Path | flowlibs_OneDriveSyncFolderPath | String | (none) | Destination folder path in the connection owner's OneDrive |
Connectors & Connections
| Connector | API Name | Connection Format | Usage |
|---|---|---|---|
| SharePoint | shared_sharepointonline | flowlibs_sharedsharepointonline_bedb3 | Trigger OnNewFile + GetFileContent |
| OneDrive for Business | shared_onedriveforbusiness | new_sharedonedriveforbusiness_53153 | CreateFile — write mirrored file |
| Office 365 Outlook | shared_office365 | new_sharedoffice365_ac201 | SendEmailV2 — success/too-large/failure notifications |
Customization Guide
1. Import solution; set the 3 env vars; update SharePoint, OneDrive, Outlook connection refs.
2. Edit varNotificationEmail and varMaxFileSizeMB literals.
3. Turn on.
**Common Modifications:** mirror to SharePoint instead of OneDrive; promote notification email to env var; add modified-file branch; add file-extension deny-list; replace email with Teams adaptive cards; add concurrency throttling.
Key Expressions
- @parameters('flowlibs_SharePointSiteURL') — read site URL
- @lessOrEquals(div(triggerOutputs()?['body/Length'], 1048576), variables('varMaxFileSizeMB')) — size check
- @concat(variables('varOneDriveSyncFolder'), '/', triggerOutputs()?['body/{FilenameWithExtension}']) — destination path