Product Discontinuation Alert Workflow
Daily flow checks for Salesforce products marked as inactive/discontinued in the last 24 hours, alerts the sales team via Teams and emails affected account owners with open opportunities on those products.
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
CF-246 - Product Discontinuation Alert Workflow is a Beginner-level scheduled cloud flow that monitors Salesforce for products marked as inactive or discontinued, then alerts the sales team via Microsoft Teams and sends email notifications to affected account owners. It runs daily at 8:00 AM UTC to catch any products deactivated in the previous cycle.
Use Case
When a product is discontinued in Salesforce, sales representatives with open opportunities tied to that product need immediate notification. This flow automates that alert chain by querying Salesforce for inactive products, building an HTML summary table, posting a consolidated alert to a Teams channel, sending a high-importance email to the sales alert distribution list, and sending a normal-priority digest copy to a separate recipient.
Flow Architecture
Recurrence
Recurrence (Schedule)Runs daily at 8:00 AM UTC to scan Salesforce for newly discontinued products.
Initialize Variables (Parallel)
Initialize variable (x6)In parallel, initializes varTeamsGroupId, varTeamsChannelId, varSalesAlertEmail, and varDigestRecipientEmail from environment variables, plus varDiscontinuedCount (Integer = 0) and varAlertHtml (String = "").
Get Discontinued Products
Salesforce - Get itemsQueries the Product2 table with filter IsActive eq false, ordered by LastModifiedDate desc, top 50.
Check If Discontinued Products Found
If conditionEvaluates length(body('Get_Discontinued_Products')?['value']) > 0 to decide whether to send alerts.
- For Each Discontinued Product — Iterates each returned Salesforce product, incrementing varDiscontinuedCount and appending an HTML <tr> row (Name, ProductCode, Family, LastModifiedDate) to varAlertHtml.
- Compose Alert Email Body — Wraps the accumulated HTML rows in a styled <table> with header row and count summary.
- Post Alert To Teams Channel — Posts the composed alert message to the configured Teams channel using varTeamsGroupId and varTeamsChannelId.
- Send Alert Email To Sales Team — Sends the composed HTML body to varSalesAlertEmail with High importance.
- Send Digest Copy — Sends a Normal-importance copy of the digest email to varDigestRecipientEmail.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_TeamsGroupId | String | <configure> | GUID of the target Microsoft Teams group/team for channel posts. Set to your Teams group ID. |
| flowlibs_TeamsChannelId | String | <configure> | ID of the Teams channel where alert messages are posted. Set to your channel ID (e.g. 19:xxxxxx@thread.tacv2). |
| flowlibs_SalesAlertRecipientEmail | String | <configure> | Distribution list address for high-importance sales alerts (e.g. sales-alerts@yourcompany.com). |
| flowlibs_DigestRecipientEmail | String | <configure> | Recipient mailbox for the normal-priority digest copy (e.g. alerts@yourcompany.com). |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Salesforce | shared_salesforce | GetItems (Query Product2 for IsActive eq false) |
| Microsoft Teams | shared_teams | PostMessageToChannelV3 (Post consolidated alert to Teams channel) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (High-importance sales alert) SendEmailV2 (Normal-importance digest copy) |
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 schedule
- Edit the Recurrence trigger to adjust frequency or time zone.
- Modify the Salesforce filter
- Update the OData filter in 'Get Discontinued Products' to target different criteria (e.g., filter by ProductFamily, add date range with LastModifiedDate).
- Customize the email template
- Edit the 'Compose Alert Email Body' action to change HTML styling or add/remove columns from the product table.
- Add more recipients
- Update the environment variable values or add additional Send Email actions.
- Enable the flow
- Toggle the flow to On after configuring environment variable values for your environment.
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.01Condition check - products found
Used in the If condition to decide whether to send alerts.
EXPR.02For Each source
Iterates each Salesforce product record returned by the query.
EXPR.03HTML row append
Builds a <tr> with product Name, ProductCode, Family, and LastModifiedDate from each Salesforce item.
EXPR.04Increment discontinued count
Tracks total discontinued products for the summary line in the email body.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.