Dynamic Salesforce Object Export to Excel
Salesforce action: GetRecords. Parameterized flow accepts an object type name, retrieves all records of that type from Salesforce, writes them to a dynamically named Excel workbook on SharePoint for ad-hoc data extraction needs.
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
A manually triggered, parameterized flow that accepts a Salesforce object API name (e.g., Account, Contact, Opportunity), retrieves records of that type from Salesforce, normalizes them into a standard schema via a Select action, and writes each record as a row in an Excel workbook on SharePoint. Designed for ad-hoc data extraction needs where business users need quick Salesforce data exports without writing SOQL or using Data Loader.
Use Case
IT admins and operations teams frequently need to pull data from Salesforce for analysis, audits, or reporting. This flow eliminates the need for Salesforce-specific tools by providing a self-service button in Power Automate. Users specify the object type, optional filter, and max record count — the flow handles the rest, writing structured data into a shared Excel workbook on SharePoint.
Flow Architecture
Manually trigger a flow
Manual button triggerButton trigger with 3 text inputs: Object_Type_Name (required) — Salesforce object API name (e.g., Account, Contact, Opportunity); Max_Records (optional) — maximum records to retrieve, defaults to 100; Filter_Expression (optional) — OData filter expression (e.g., IsActive eq true).
Initialize variables (5x parallel)
Initialize variableBinds environment variables and sets up working variables: varSharePointSiteUrl ← flowlibs_SharePointSiteURL env var; varExcelFilePath ← flowlibs_ExportExcelFilePath env var; varExcelTableName ← flowlibs_ExportExcelTableName env var; varExportedCount ← integer 0 (running count of exported records); varMaxRecords ← trigger input or default '100'.
Get Salesforce Records
Salesforce — Get itemsSalesforce connector GetItems with dynamic table (object type from trigger input), $top (from varMaxRecords), and optional $filter (from trigger input).
Select Record Fields
Data Operation — SelectNormalizes heterogeneous Salesforce objects into a standard 7-column schema using coalesce() fallbacks: RecordId, RecordName, RecordType, Field1, Field2, Field3, ExportDate.
For Each Record (Sequential)
Apply to eachFor each normalized record: writes the row to Excel via Excel Online AddRowV2 against the target workbook/table, then increments varExportedCount.
Compose Export Summary
ComposeConcatenates the final export count, object type, file path, and timestamp into a summary string.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com | Target SharePoint site for the Excel workbook. |
| flowlibs_ExportExcelFilePath | String | /Shared Documents/FlowLibs - Salesforce Export.xlsx | Server-relative path to the Excel file the flow writes rows into. |
| flowlibs_ExportExcelTableName | String | SalesforceExport | Name of the table inside the Excel workbook (must pre-exist with the expected columns). |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Salesforce | shared_salesforce | GetItems (Retrieve records dynamically by object type) |
| Excel Online (Business) | shared_excelonlinebusiness | AddRowV2 (Write rows to Excel table on SharePoint) |
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.
- Create the Excel workbook
- On your SharePoint site, create an Excel file at the path specified in flowlibs_ExportExcelFilePath. Inside it, create a Table named per flowlibs_ExportExcelTableName with columns: RecordId, RecordName, RecordType, Field1, Field2, Field3, ExportDate.
- Update environment variables
- Set flowlibs_SharePointSiteURL to your SharePoint site URL, and update the file path and table name if they differ from the defaults.
- Authorize connections
- Open the flow in the designer and authorize both the Salesforce and Excel Online (Business) connections.
- Turn on the flow
- Change the flow state from Off to On so it can be invoked.
- Run it
- Click Run and provide the Salesforce object API name (e.g., Account), optionally setting Max_Records and Filter_Expression.
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 max records with default
Falls back to 100 when the Max_Records trigger input is empty.
EXPR.02Null-safe record name
Picks the first non-null label across heterogeneous Salesforce objects, falling back to the record Id.
EXPR.03Multi-field fallback
Used in the Select action to populate a generic Field column from whichever Salesforce field exists on the object.
EXPR.04Export summary
Builds the final Compose output reporting the exported count and object type.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.