I denne tutorial vil vi tale om Power Automate Switch-kontrol , som er under de avancerede indbyggede stik. Der er tidspunkter, hvor vi har flere mulige værdier, der kommer med forskellige arbejdsgange. Vi kan gøre det ved at bruge indlejrede tilstandshandlinger, men det kan blive for kompliceret, når antallet af mulige værdier bliver højere. Det er meget bedre at have betingelserne side om side og analysere dem individuelt. I så fald bruger vi Switch-handlingen.
Switch-kontrol i Power Automate kan håndtere flere tilfælde af mulige alternativer, som har forskellige handlinger eller blokke af udsagn.
Indholdsfortegnelse
Oprettelse af et kraftautomatiseringsflow
Lad os først skabe et nyt øjeblikkeligt flow.

Lad os sætte navnet til " Advanced Built-in Connector Demo ". Vi vil skabe et flow, der udløses manuelt. Så vælg indstillingen " Udløs et flow manuelt ", og klik derefter på knappen Opret .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik derefter på knappen Nyt trin .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Lad os se de indbyggede stik, der er tilgængelige.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik på kontrolstikket .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Kontrolstikket har seks forskellige handlinger. Vi har allerede diskuteret i en af vores tutorials. Igen opdeler denne kontrol strømmen baseret på, om en betingelse er sand eller falsk.
Lad os tilføje nogle input i vores flow, hvor brugeren kan indtaste en leveringsmetode og besked via tekstinput . Lad os også give dem flere valg at vælge imellem ved hjælp af en rulleliste.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
For dette flow, hvis den valgte leveringsmetode er Tweet , skal vi udføre en Tweet- handling. Hvis det er e-mail , skal vi udføre en e-mail- handling. Det samme gælder for alle de andre muligheder. Hvis vi bruger Condition- kontrolelementet til at udføre processen, så opretter vi en indlejret tilstand, der ligner denne.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Det er dybest set en IF-erklæring under en anden IF-erklæring, hvilket kunne være besværligt. Derfor har vi brug for Switch- kontrollen for at forenkle processen.
Brug af kontaktstyring i Power Automate
For dette eksempel, lad os vælge Switch- kontrollen.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Det gode ved Switch- styring er, at vi kun skal vælge én variabel, som vi vil teste. For feltet Til skal du vælge variablen Leveringsmetode .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
1. Tilføjelse af det første afbryderhus
Under sagssektionen kan vi indstille de flere ruter for hver leveringsmetode. Lad os indsætte det første valg, som er " Tweet ".
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik derefter på knappen Tilføj en handling .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Søg og vælg Twitter- forbindelsen.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Vælg Send et tweet .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
For Tweet- tekstfeltet skal du vælge Besked.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
2. Tilføjelse af de andre switche
For at tilføje endnu en Switch- sag skal du klikke på dette ikon ved siden af den første sag.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Lad os skrive den anden mulighed, som er " E-mail ".
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik på knappen Tilføj en handling .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Søg og vælg Mail- forbindelsen.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Vælg derefter handlingen Send en e-mail-meddelelse (v3) .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Indstil e-mailadressen til det sted, hvor du ønsker, at meddelelsen skal sendes. Vælg meddelelsesvariablen for både Emne- og Brødtekst- felterne.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Tilføj det tredje tilfælde for Slack- indstillingen, og indstil derefter kanalnavnet til Tutorial. Brug meddelelsesvariablen til feltet Beskedtekst .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Derefter tilføjes det fjerde tilfælde ( Trello ). Indstil bestyrelses-id til Opgaver og forældreliste-id til problemer . Brug blot meddelelsesvariablen til både kortnavn og kortbeskrivelse felterne.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Standardkortet er det sted, hvor vi kan indstille en anden handling, hvis ingen af de tilgængelige leveringsmetoder matcher den, der blev indtastet af brugeren . Men i dette eksempel har vi ikke brug for det, da vi tvinger brugeren til kun at vælge mellem de fire muligheder.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik til sidst på Gem .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Test af kontaktkontrol i Power Automate
Lad os nu prøve vores flow. Klik først på Test .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Vælg indstillingen Jeg udfører udløserhandlingen , og klik derefter på knappen Test .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik derefter på knappen Fortsæt .
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Sådan ser formen ud. Vælg Slack som leveringsmetode. Skriv derefter " HEJ ALLE! DET ER A-ME MARIO! ”. Klik på knappen Kør flow , og lad os også se det i aktion.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Klik på Udført.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Vi kan nu se, at blandt de fire sager var det kun Case 3 , der blev aktiveret. Og det kan vi identificere via de grønne flueben.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Når vi tjekker vores Slack, vil vi se den nyligt indsendte besked.
![Power Automate Switch Control Action I Workflows Power Automate Switch Control Action I Workflows]()
Og så enkelt fungerer Switch- kontrollen i Power Automate.
Konklusion
For at opsummere er vi i stand til at skabe et flow med Switch- kontrol og differentiere det fra Condition- kontrol. Sidstnævnte deler flowet mellem " Ja " eller " Nej "-betingelser og tilføjer en betingelse over en anden afhængigt af antallet af muligheder.
På den anden side lader Switch-kontrol brugere udføre flere stablede forhold inden for en enkelt linje. Det ligner meget alle andre switch-case-udsagn, som du ser i Python og andre programmeringssprog.
Derfor, hvis argumentet på dit flow blot er mellem en simpel "ja" eller "nej" betingelse, så kan du bruge Condition- kontrollen. Men hvis du har flere muligheder, er det bedre at bruge Switch- etuier i stedet for stablede forhold. Forhåbentlig var du i stand til at forstå den korrekte brug af disse to indbyggede stik.
Alt det bedste,
Henrik