SQL Server with Mr. Denny

Oct 7 2019   4:00PM GMT

Doing something in a loop in Microsoft flow, and something else if there’s no match

Denny Cherry Denny Cherry Profile: Denny Cherry

Tags:

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.

Denny

 

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: