Bulk Job Error Analysis & Retry Workflow
Salesforce action: GetJobResults. Retrieves results from a completed bulk job, separates successful vs. failed records, saves the error file to SharePoint, posts an error summary to Teams, and optionally creates a retry job with only the failed records.
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 scheduled flow inspects completed Salesforce Bulk API 2.0 jobs, separates successful from failed records, archives error rows to SharePoint, posts an HTML summary to Microsoft Teams, and optionally opens a new retry bulk job with only the failed rows.
Use Case
Bulk ingest jobs often fail partially due to validation errors, lock contention, or data quality issues. Manual post-processing is error-prone and delays recovery. This flow automates error analysis and retry, keeping failed data auditable in SharePoint while enabling self-healing retry loops without operator intervention.
The flow is ideal for teams that:
- Automatic post-processing of completed bulk jobs — no manual CSV analysis
- Failed records archived to SharePoint for compliance and future analysis
- Optional auto-retry with single-click configuration — failed rows resubmitted immediately
- HTML summary to Teams keeps ops team aware of job status
- Zero silent failures — every bulk job gets admin notification
Flow Architecture
Recurrence - Every 2 Hours
RecurrenceChecks job status on regular schedule (configurable frequency).
Initialize Variables (8x)
Initialize variableLoad env vars: SalesforceCompletedBulkJobId, SharePointSiteUrl, ErrorFolderPath, AdminTeamsGroupId, AdminTeamsChannelId, AutoRetryEnabled, RetryObjectName, RetryOperation.
Get Job Info
Salesforce GetJobInfoFetch job metadata and current state from Salesforce Bulk API 2.0.
If Job Complete Or Failed
If conditionCheck whether the bulk job state is 'JobComplete' or 'Failed'.
- Get Failed Records CSV — Salesforce GetJobRecordResults with resultType: failedResults.
- Get Successful Records CSV — Salesforce GetJobRecordResults with resultType: successfulResults.
- Compose Error File Name — Generate timestamped filename: BulkJob-{id}-FailedRows-{yyyyMMdd-HHmmss}.csv.
- Create Error File on SharePoint — SharePoint CreateFile — archive failed CSV to configured folder.
- Compose Error Summary HTML — Build styled HTML report with job ID, record counts, and failed CSV link.
- Post Error Summary to Teams — Teams PostMessageToConversation — notify admin channel.
- If Auto-Retry Enabled — Nested condition — if flowlibs_CF266_AutoRetryEnabled equals 'true', create and start a retry bulk job (CreateJobV2 → UploadJobData → CloseJob → Post Retry Started to Teams).
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com/sites/<configure> | Host SharePoint site URL for the error CSV archive. |
| flowlibs_AdminTeamsGroupId | String | <configure> | Teams group (team) ID for admin notifications. |
| flowlibs_CF266_AutoRetryEnabled | String | false | Set to 'true' to automatically create a retry job for failed records; any other value disables retry. |
| flowlibs_CF266_RetryOperation | String | update | Bulk operation for the retry job: insert, update, upsert, or delete. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Salesforce | shared_salesforce | GetJobInfo GetJobRecordResults CreateJobV2 UploadJobData CloseJob |
| SharePoint Online | shared_sharepointonline | CreateFile (archive error CSV) |
| Microsoft Teams | shared_teams | PostMessageToConversation (admin notifications) |
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.
- Deploying to another environment
- Import the solution, set all eight env vars to your target Salesforce job, SharePoint site, Teams channel, and retry configuration, bind the three connection references (Salesforce, SharePoint, Teams), configure the SharePoint error folder (create manually if it doesn't exist), and turn the flow on.
- Change schedule cadence
- Edit the Recurrence trigger frequency — e.g., Minute interval 30 for 30-minute checks in test environments.
- Multiple jobs per run
- Replace the single flowlibs_SalesforceCompletedBulkJobId variable with a Dataverse table of queued jobs and wrap the core logic in Apply to each.
- Custom error filename
- Modify the Compose_Error_File_Name expression to add an environment prefix (e.g., 'prod-', 'uat-').
- Turn off retry entirely
- Set flowlibs_CF266_AutoRetryEnabled to any value other than 'true' to skip the CreateJobV2 → UploadJobData → CloseJob sequence.
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.01Error filename with timestamp
Generates a unique CSV filename per run using the job ID and a UTC timestamp.
EXPR.02Job-complete gate
True when the Salesforce bulk job has finished (success or failure) and is ready for post-processing.
EXPR.03Auto-retry gate
Case-insensitive check on the auto-retry env var; only the literal 'true' enables the retry branch.
EXPR.04Retry job linking
Extracts the new bulk job ID from the CreateJobV2 response for use in UploadJobData and CloseJob.
EXPR.05Record count for report
Used in the HTML Teams summary to show how many records failed.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.