Scheduled Bulk Data Export Job Launcher
Salesforce action: CreateJob_V2. Weekly scheduled flow creates a bulk query job in Salesforce for archival export (e.g., all closed Opportunities from prior quarter), monitors job completion, retrieves results, and saves the CSV to SharePoint.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow automates the process of exporting large datasets from Salesforce using the Bulk API 2.0. It creates a bulk query job, monitors it until completion, retrieves the CSV results, and saves them to a date-stamped file in SharePoint for archival or downstream analysis (e.g., Power BI consumption).
Use Case
Organizations that need to periodically archive Salesforce data — such as all closed Opportunities from the prior quarter — can use this flow to automate the entire bulk export lifecycle. The flow handles job creation, polling for completion, result retrieval, and file storage without manual intervention.
Example scenario: Every Saturday at 2 AM EST, export all closed Opportunities from the prior quarter to a CSV file in SharePoint for compliance archival and Power BI reporting.
Flow Architecture
Recurrence
RecurrenceWeekly, Saturday at 2:00 AM Eastern Standard Time.
8x Parallel Initialize Variable
Initialize variableBinds all 6 environment variables to runtime variables, plus initializes varPollCount (integer, 0) and varJobComplete (boolean, false).
Create Bulk Query Job
Salesforce CreateJob_V2Creates a bulk query job for the configured object type with CSV output and LF line endings.
Upload SOQL Query to Job
Salesforce UploadJobDataSends the configurable SOQL query string to the bulk job.
Close Job to Begin Processing
Salesforce CloseOrAbortJobSets the job state to UploadComplete to trigger server-side processing.
Poll Until Job Complete
Do UntilPolls with configurable interval and max attempts. For each iteration: delays varPollInterval minutes, calls Salesforce GetJobInfo to retrieve current job state, increments varPollCount, then checks if state is JobComplete, Failed, or Aborted — if so, sets varJobComplete = true.
Check Final Job State
Salesforce GetJobInfoFinal status read after polling exits.
Check If Job Succeeded
If conditionBranches on whether the final job state equals JobComplete.
- Get Bulk Job Results — Salesforce GetJobResults: retrieves the CSV data.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_BulkExportSOQLQuery | String | SELECT Id, Name, StageName, Amount, CloseDate, OwnerId FROM Opportunity WHERE IsClosed = true AND CloseDate = LAST_QUARTER | The SOQL query for the bulk job. |
| flowlibs_BulkExportSalesforceObject | String | Opportunity | The Salesforce object type for the bulk query. |
| flowlibs_BulkExportSharePointFolder | String | /Shared Documents/FlowLibs - Bulk Exports | Server-relative path for saving exported CSVs. |
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com | SharePoint root site URL (shared). Set to your tenant's SharePoint root, e.g. https://contoso.sharepoint.com. |
| flowlibs_BulkJobPollIntervalMinutes | String | 5 | Minutes between each poll (shared). |
| flowlibs_BulkJobMaxPolls | String | 60 | Maximum polling attempts before timeout (shared). |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Salesforce | shared_salesforce | CreateJob_V2 (Creates the bulk query job) UploadJobData (Sends the SOQL query) CloseOrAbortJob (Marks the job UploadComplete) GetJobInfo (Polls and reads final state) GetJobResults (Retrieves the CSV results) |
| SharePoint Online | shared_sharepointonline | CreateFile (Saves the exported CSV) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Change the export object
- Update flowlibs_BulkExportSalesforceObject to any Salesforce standard or custom object (e.g., Account, Contact, Case, CustomObject__c).
- Change the query
- Update flowlibs_BulkExportSOQLQuery with the desired SOQL. Supports WHERE clauses, date literals (LAST_QUARTER, THIS_YEAR), and field selection.
- Change the schedule
- Edit the Recurrence trigger to run daily, monthly, or on specific weekdays.
- Change the destination
- Update flowlibs_BulkExportSharePointFolder to any document library path, and flowlibs_SharePointSiteURL to any site.
- Adjust polling
- Increase flowlibs_BulkJobPollIntervalMinutes for very large exports (millions of records) or decrease for faster feedback on small jobs.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Dynamic file name
Builds a date-stamped CSV file name from the object type and current UTC timestamp.
EXPR.02Poll exit condition
Exits the Do Until loop when the job reaches a terminal state or when the maximum number of polls is reached.
EXPR.03Terminal state check
Treats JobComplete, Failed, and Aborted as terminal states so the loop stops polling.
EXPR.04Null-safe record counts
Coerces a possibly-null records-processed count to '0' for the summary message.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.