DEV Community

Cover image for Notify the Role, Never the Person
HokaGue-Devs
HokaGue-Devs

Posted on

Notify the Role, Never the Person

A validation workflow with four levels will, sooner or later, break this rule:
someone sends an email notification to a specific person instead of to
whoever currently holds the role. It looks harmless - "just email the
manager" - until that manager goes on leave, changes team, or the role gets
reassigned, and the notification keeps going to someone who no longer has
any say in the decision.

The invariant

Notifications target a role, never a person. The recipient is derived
from the role expected at the workflow level being notified - and every
holder of that role receives it.

function recipientsFor(level: WorkflowLevel, entityId: string): User[] {
  // resolves to "everyone currently holding the expected role for this level
  // and entity" - never a stored person reference
}
Enter fullscreen mode Exit fullscreen mode

Why "just email the person" always comes back to bite

  • Roles change, hardcoded emails don't. The day someone leaves or switches teams, every notification still pointing at them silently stops reaching anyone who can act.
  • Delegation becomes possible for free. If the recipient is "whoever holds this role," adding a temporary delegate (someone on leave) is a one-line change to role resolution - not a hunt through every place an email address was hardcoded.
  • Auditability. "Who was supposed to be notified at level 3 last March" is answerable from role history, not from a snapshot of someone's inbox three resignations ago.

The practical rule of thumb

If your notification code reads a person's name, email, or user ID directly
from a record instead of asking "who currently holds the expected role here,"
that's the bug waiting for the next org change.


I work on Power Platform / Dataverse architecture (Code Apps, approval
workflows, role-based notifications). Happy to discuss your project's
architecture if you're scoping something similar.

Top comments (0)