User Department Change Notifier
Scheduled flow compares current user departments against a baseline in SharePoint; when a change is detected, notify HR and the user's new manager.
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
The User Department Change Notifier is a scheduled Power Automate Cloud Flow that runs daily to detect when employees have changed departments. It compares each user's current Office 365 department against a baseline stored in a SharePoint list. When a mismatch is found, the flow updates the baseline, builds an HTML change report, and emails it to the HR team.
Use Case
Organizations need visibility into department transfers for compliance, access reviews, and onboarding coordination. This flow eliminates manual cross-referencing by automatically scanning user profiles daily and flagging changes to HR.
The flow is ideal for teams that:
- Detecting lateral transfers, promotions, or reorganizations
- Triggering downstream processes like access reviews or seating updates
- Maintaining an auditable history of department assignments over time
Flow Architecture
Daily Recurrence
Recurrence triggerFires every day at 8:00 AM Eastern.
Initialize Variable - SharePoint Site URL
Initialize variableLoads the SP site URL from the flowlibs_SharePointSiteURL environment variable.
Initialize Variable - Baseline List Name
Initialize variableLoads the baseline list name from the flowlibs_DeptBaselineListName environment variable.
Initialize Variable - HR Email
Initialize variableLoads the HR notification email from the flowlibs_HRNotificationEmail environment variable.
Initialize Variable - Changes Detected Count
Initialize variableInteger counter starting at 0.
Initialize Variable - Change Summary HTML
Initialize variableEmpty string to accumulate HTML table rows.
Get Baseline Items from SharePoint
Get items (SharePoint)Retrieves all rows from the Department Baseline list.
Loop Through Each Baseline User
Apply to eachFor each user in the baseline list: get the current Office 365 profile, compare departments, and either record a change or just update the LastChecked timestamp.
Check If Department Changed
If conditionInside the loop, compares the current Office 365 department against the baseline department for the user.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com | Root SharePoint site URL (shared across FlowLibs solutions). |
| flowlibs_DeptBaselineListName | String | FlowLibs - Department Baseline | Name of the SharePoint list storing department snapshots (columns: UserEmail, UserDisplayName, Department, LastChecked). |
| flowlibs_HRNotificationEmail | String | hr@yourcompany.com | Recipient email address for the department change report. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SharePoint Online | shared_sharepointonline | GetItems (read baseline items) PatchFileItem (update baseline records / LastChecked) |
| Office 365 Users | shared_office365users | UserProfile_V2 (look up current user department by email) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (send the HTML change report email) |
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 scan schedule
- Edit the Daily Recurrence trigger to adjust the frequency (e.g., weekly) or the time of day the scan runs.
- Add more users
- Add rows to the 'FlowLibs - Department Baseline' SharePoint list with each user's email, display name, and current department so they're included in the daily comparison.
- Notify the user's manager
- Add an Office 365 Users 'Get manager' action after a change is detected and CC the manager on the notification email.
- Track change history
- Add a second SharePoint list ('Department Change Log') and insert a new row for each detected change to create an audit trail of all moves over time.
- Port to another tenant
- Update the three environment variable values and re-authenticate the three connection references after importing the solution into a new tenant.
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.01Null-safe department comparison
Used on both sides of the equality check against coalesce(items('Loop_Through_Each_Baseline_User')?['Department'], '') so a null department doesn't false-positive as a change.
EXPR.02Date stamp for subject line
Appended to the email subject so each daily report is uniquely tagged.
EXPR.03Dynamic change count in subject
Embeds the total number of detected department changes directly in the email subject line.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.