SharePoint Document Library
Definition
The SharePoint Document Library trigger automatically initiates a flow whenever a specific change occurs to a file or folder within a selected SharePoint library. Unlike standard triggers that only detect creation or modification, this trigger offers comprehensive lifecycle monitoring. It can distinguish between granular events such as items being renamed, moved into or out of the library, or even restored from the recycle bin.
Key capabilities include:
- Extensive Event Coverage Monitor specific actions for both Files and Folders, including when items are added, updated, deleted, renamed, or restored from the recycle bin.
- Movement Tracking Detect when items are moved within the library, moved away to a different library, or moved into the current library from elsewhere—critical for tracking document location.
- Precise Scope Configurable to listen to a specific Site ID and Drive ID, ensuring the flow only reacts to changes in the relevant document library.
This trigger is essential for building advanced governance and compliance workflows, allowing you to maintain a perfect sync between your SharePoint environment and your automated business processes.
Example Use Cases
-
Security Alert for Moved Files Trigger a flow when a File moved away from the selected library to instantly detect if a sensitive HR or legal document is moved to an unauthorized location, allowing you to notify security or revoke access.
-
Audit Restored Items Automatically log an entry in a compliance table when a File restored from the recycle bin, capturing who restored the file and when, to maintain a complete history of data recovery actions.
-
Sync External References Update file links in a connected CRM or project management tool when a File renamed or moved within the selected library occurs, ensuring that users always have access to the correct file path.
-
Process Incoming Contracts Start an approval or signature workflow automatically when a File moved into the selected library from another library (e.g., from “Drafts” to “Final”), signaling that the document is ready for the next stage.
-
Replicate Folder Structure Trigger a flow when a Folder added event occurs to automatically create a matching folder in a secondary storage system like Google Drive or Dropbox, keeping your backup directory structure identical to SharePoint.
Configuration
The configuration for the SharePoint Document Library trigger is divided into two main parts: Settings and Conditional Run.
Settings
These settings define the scope of your monitoring, specifying which SharePoint site and library to watch and exactly which events should trigger the flow.
-
Connection
This field establishes the secure link between Zenphi and your SharePoint environment.
- Purpose: To authorize Zenphi to access your organization’s sites, libraries, and files.
- How to use: Select an existing SharePoint connection from the dropdown list. If you haven’t connected one yet, click the
+button to authenticate with your Microsoft account. This is a one-time setup per connection. - Use Case: You need this to ensure the flow has the permissions required to “see” the files and read their properties.
-
Event Type
This determines the specific action that will activate the flow. The trigger will only fire for the event selected here.
- Purpose: To filter the noise and ensure your flow only runs for relevant changes.
- How to use: Select the specific event from the dropdown menu. Options include: * File Events: New file added, File updated, File deleted, File renamed or moved within…, File moved away…, File moved into…, File restored… * Folder Events: Folder added, Folder updated, Folder deleted, Folder renamed or moved within…, Folder moved away…, Folder moved into…, Folder restored…
- Use Case: You would select File moved into the selected library from another library to trigger a “Final Review” flow only when a document is promoted from a “Drafts” library to the “published” library.
-
Site Id
This identifies the specific SharePoint Site (or Team Site) where the document library is located.
- Purpose: To narrow down the monitoring scope to a specific workspace within your organization’s SharePoint environment.
- How to use: Click the dropdown to browse and select the name of the SharePoint site. If working with a dynamic environment, you can technically map this ID, but for triggers, it is almost always a static selection to ensure reliability.
- Use Case: Select the “HR Department” site to ensure you are only watching HR-related documents, ignoring similar libraries in the “Sales” site.
-
Drive Id
This identifies the specific Document Library (often called a “Drive”) within the selected Site.
- Purpose: To pinpoint the exact “file cabinet” or library you want to watch.
- How to use: After selecting a Site, use this dropdown to choose the library name (e.g., “Documents”, “Invoices”, “Shared Documents”).
- Use Case: You would use this to target the specific “Confidential Contracts” library, distinguishing it from the general “Shared Documents” library on the same site.
-
Columns to return
This allows you to customize the output by selecting which metadata fields (columns) the trigger should retrieve.
- Purpose: To optimize flow performance by fetching only the data you actually need.
- How to use: Select the specific columns from the list. If you only need the file name and owner, select those. If you leave this default or blank, it may return standard properties.
- Use Case: If your library has 50 custom columns but you only need the File Name to send an email notification, select only “Name” here to keep the data payload small and fast.
Conditional Run
The Conditional Run feature allows you to control whether a flow should proceed based on the specific details of the file or folder event. This is especially useful in large document libraries where you might only want to process a small subset of files—for example, only contracts in a specific folder or only files with a certain naming convention.
If the conditions are not met, the flow will be skipped, saving run credits and keeping your logs clean.
How Conditional Run Works
When enabled, Conditional Run allows you to define one or more conditions using AND / OR logic. Each condition includes four elements:
-
Condition Type
- When: The flow will run only if the condition is true.
- Except When: The flow will not run if the condition is true.
-
Value to Evaluate
Choose the field from the trigger outputs that you want to check. Common fields include:
- Item Name – To check the file name or extension (e.g., does it end in
.pdf? Does it start withBudget_?) - Item Path – To check where the file is located (e.g., is it inside the
/Confidential/sub-folder?) - Item Deleted – A True/False value to check if the item is currently deleted.
- Event Type – To confirm the specific action that occurred.
- Item Name – To check the file name or extension (e.g., does it end in
-
Operator
Define how the comparison will be made. Options include:
- Text Comparisons: Equals, Contains, Starts With, Ends With
- Logic Comparisons: Is True, Is False (useful for the
Item Deletedfield) - Status Checks: Is Null, Is Not Null
-
Comparison Value
Set the value to compare against. This can be:
- A fixed text (e.g.,
".xlsx","Finance Folder") - A Vault variable (for secure or managed values)
- A fixed text (e.g.,
Example Conditions
-
Process PDF Files Only Run the flow When
Item NameEnds With".pdf"(Useful for OCR or document parsing workflows) -
Restrict to a Specific Sub-Folder Run the flow When
Item PathContains"/Invoices/2024/"(Ensures the flow ignores files in other directories like “Drafts” or “Archive”) -
Ignore Temporary Files Run the flow Except When
Item NameStarts With"~"(Prevents the flow from running on temporary lock files created by Word or Excel) -
Exclude Deletions Run the flow When
Item DeletedIs False (Ensures the flow only attempts to process files that still exist and haven’t been deleted) -
Target “Urgent” Files Run the flow When
Item NameContains"URGENT"(Prioritizes processing for files clearly marked as urgent in their filename)
Outputs
When the SharePoint Document Library trigger fires, it captures detailed information about the file or folder and the specific event that occurred. These outputs are available throughout your flow via the Token Picker, allowing you to use the file’s data in subsequent actions or to refine your logic in the Conditional Run.
-
Event Type The specific type of change that triggered the flow (e.g.,
ItemAdded,ItemUpdated,ItemMoved,ItemDeleted). You can use this to create branching logic within your flow—for example, sending a “Review Request” email if the event isItemAdded, but an “Archive Notification” if the event isItemMoved. -
Event Time The date and time (in UTC) when the change actually occurred in SharePoint. This is essential for audit trails, allowing you to log the exact moment an event happened in a database or Zenphi Table.
-
Item Name The name of the file or folder (e.g.,
Contract_Final.pdf). This is critical for filtering and file handling. You can use it to check for specific keywords (like “Invoice”) or pass it to a “Save File” action to preserve the original filename in another system. -
Item Path The relative path to the item within the document library (e.g.,
/Finance/2024/Invoices/file.pdf). This allows you to replicate the exact folder structure in a destination system (like Google Drive) or filter the flow so it only processes files located inside specific sub-folders.
-
Item Created Date/Time The date and time (in UTC) when the file was originally created. Use this to calculate the age of a document or to organize files into chronological folders (e.g., creating a folder named “2024-Q1” based on this date).
-
Item Modified Date/Time The date and time (in UTC) when the file was last modified. You can compare this timestamp against a previous sync time to determine if a record needs updating or to identify the most recent version of a file.
-
Item Deleted A True/False (Boolean) value indicating whether the item has been deleted. You can use this in an If/Else condition to safeguard your flow—for example, ensuring you don’t try to “Get File Content” for a file that no longer exists.
-
File Contents The actual binary content of the file. This is the most critical output for migration or backup flows. You pass this token to actions like Google Drive > Create File or Send Email (as an attachment) to move, copy, or share the actual document.
-
Description The text entered in the SharePoint “Description” field for the file, if applicable. This can be used to populate notes, summaries, or ticket details in external tracking tools like Jira or Trello.
-
Image Tags If your SharePoint library uses automatic image tagging, this object contains the analysis results (including Label, TermGuid, and WssId). This is powerful for Digital Asset Management (DAM) workflows, allowing you to automatically categorize images or filter processing based on content (e.g., “Only process images labeled ‘Receipt’”).
📌 Example: Auto-Publishing Approved Policies to Google Drive
Scenario Your HR team drafts policy documents in a private “Drafts” SharePoint library. Once a policy is finalized and approved, they move the file into a separate “Public Policies” SharePoint library.
You want to automatically detect when a file enters this “Public” library and immediately publish a copy to a company-wide Google Drive folder so all employees can access it without needing SharePoint permissions.
How the Flow Works
- Trigger:
The flow starts when a file is moved into the target library.
- Event Type:
File moved into the selected library from another library - Site Id:
HR Portal - Drive Id:
Public Policies
- Event Type:
- Conditional Run:
You want to ensure only PDF files are published (ignoring Word docs that might still be in editing).
Item NameEnds With.pdf
- Steps in the Flow:
- Get File Content: (Implied via Trigger Output) The flow uses the File Contents token from the trigger to grab the actual document data.
- Create File: A Google Drive > Create File action saves the document into the “All Company Policies” folder on Google Drive.
- Post Message: A Slack > Post Message action notifies the
#generalchannel: “New Policy Published: [Item Name]”.
Why It’s Useful This automation creates a seamless “drag-and-drop” publishing workflow for the HR team. They simply move a file in SharePoint, and the flow handles the distribution, permission management (by moving it to a public Drive), and company-wide notification instantly.