Switch: direcționare după status

Power Automate intermediar

Dani Kahil

Solution Architect | Microsoft MVP

Condition imbricate vs Switch

nanobanana: A clean flat illustration on a pure white background showing two flow diagrams side by side. Left: a deeply nested set of three stacked Condition diamonds, each branching left and right, drawn in muted grey to suggest complexity. Right: a single Switch action shown as a rectangular box labelled "Switch" with five clean horizontal output lanes labelled Case 1, Case 2, Case 3, Case 4, Default, drawn in DataCamp green. A bold arrow points from left to right.

 

  • Condition se ramifică pe booleeni - un da/nu per acțiune
  • Switch direcționează pe o singură valoare către mai multe cazuri
  • Peste două Condition imbricate, folosește Switch
Power Automate intermediar

Anatomia unui Switch

 

screenshot_switch_action_config_panel: Power Automate Switch action expanded, showing the On field with the Status Value dynamic content token, three case slots labelled Case (Equals Active), Case (Equals Lapsed), Case (Equals Renewed), and a Default case at the bottom

 

  • On - valoarea pe care o evaluează Switch
  • Case - o ramură pentru fiecare potrivire exactă
  • Default - tot ce nu s-a potrivit
Power Automate intermediar

Cazurile trebuie potrivite exact: sensibilitatea la litere mari/mici

nanobanana: A clean flat illustration on a pure white background. Three stacked horizontal pill-shaped rows. Top row: "Active" on left, equals sign, "Active" on right, with a green checkmark beside it. Middle row: "Active" on left, equals sign, "active" on right (lowercase), with a red X beside it. Bottom row: "Active" on left, equals sign, " Active" on right (with a leading space), with a red X. All text in monospace, minimalist, DataCamp green and navy accents.

 

  • Switch compară caracter cu caracter
  • 'Active' ❌ 'active' — nepotrivire de litere mari/mici
  • Un spațiu final strică și el potrivirea
  • Soluție: toLower() sau trim() înainte de Switch
Power Automate intermediar

De ce Default este obligatoriu

 

screenshot_switch_run_history_no_default_no_match: Power Automate run history showing a Switch action expanded with all three cases displayed as Skipped, no Default case present, and the overall run status showing green Succeeded

 

  • Fără potrivire + fără Default → rulează cu succes, dar nu face nimic
  • Cel mai periculos tip de bug - invizibil
  • Default înregistrează valoarea neașteptată
Power Automate intermediar

Hai să exersăm!

Power Automate intermediar

Preparing Video For Download...