Recently I wanted to make a Microsoft flow process to create channels in Microsoft Teams once a project is ready to start. If the channel was already there then I wanted a message to be posted to the Teams channel saying that the project was ready, but that it didn’t need to create the channel. So in programming terms I wanted a loop, with an IF statement inside the loop. Then if the loop got to the end of the downloaded set and there was no match it should do something.
Now Microsoft Flow doesn’t include anything to do this, so I had to get a little creative.
As I was looking through Microsoft Flow I found that you could use Variables within a Microsoft Flow application, and this made things suddenly click. At the begining of the Flow I initiazlited a variable; in this case called “FoundClientInTeams”.
From here I setup a pull from Teams that would pull down all the channels for a team. That was passed to an “Apply to Each” object, which is basically a “FOR” loop.
Within that “Apply to Each” object there’s a Condition that looks to see if the client name that we’re looking for exists or not. If the channel exists (according to the condition) then the flow sends a message and changes the variable from false to true. (There’s a “No” block of this condition that doesn’t do anything.)
After the “Apply to Each” there’s another Condition block, which checks to see if the varaiblehas been reset if needed. If the value is still false, that means that there was no match found, so we need to create the channel. Is also posts a message saying that it created the channel, so there’s some debugging going on as well. The “No” side of the condition is left blank, so if the channel is found the varible is changed, and this condition should fail and nothing should be done at this point.
As I was working on this, I’m shocked to find that Microsoft flow is as poweful as it is. What we’re doing in this case, is that when a document is updated on our SharePoint O365 site (in our case the SOW status), Microsoft Flow sees the change, and them either creates a new channel for the client if they are a new client, or just posting a message if they are an existing client. Because we were able to automate this task, its one less thing that we need to do when we sign an SOW for a client.
The post Doing something in a loop in Microsoft flow, and something else if there’s no match appeared first on SQL Server with Mr. Denny.Contact the Author | Contact DCAC