Unfortunately, I haven't used Microsoft Flow in production yet. I read docs, I've tried some basic things, I saw a lot of cool presentations around MS Flow and different integration options. From what I saw and tried so far MS Flow is an extremely powerful tool to automate processes. You can do so many cool things (of course if you have enough experience)! I'm just exploring and in this post, I'm going to build a very simple Flow, which updates a SharePoint item based on different conditions. When SharePoint item is created, it will check the item's field and update the same item based on a condition.
Here is our resulting flow:
What is needed to create and run a Flow?
If you have an Office 365 license, you are good to go. With Office 365 license you have basic MS Flow capabilities. MS Flow also includes a free plan. For advanced features you should pay for P1 or P2 (Premium) licences:
Create a Flow for SharePoint item
I have a list called Office Expenses which tracks, guess what, office expenses. When a user submits a new record in the list, the flow will trigger and check if an entered amount of money is OK to be automatically approved. Based on an outcome, the status of the item will be updated with a new value.
SharePoint Online has a nice Flow menu for lists and libraries. To create a flow, click on it and select "Create a flow":
On the right side of the screen, you will see the slide out menu with different options.
We don't need pre-build templates. Go ahead and click "See your flows". You will be redirected to Flow portal. From Flow portal from the menu in the top select "Create from blank"
and then click on "Create from blank" again in a new view. I don't know why you should confirm that you want to create it from blank twice, but this is how it works :)
Add a trigger to your flow
Almost all flows start with a trigger. We are interested in SharePoint triggers. Search for "SharePoint" in the search box and select "When an item is created" in the list:
You should further configure your trigger. In our case only two fields are required - Site Address and List Name:
Implement flow's logic
When the trigger is ready, we can start adding actions. There are a lot of out of the box actions available. There are a lot of actions for SharePoint as well. But we're going to start with Condition because we need to check the cost. Click on a plus sign, search for "condition" and add "Condition" from the list of actions:
One of the coolest thing about MS Flow is that it understands the context and helps you with variables suggestion. In my condition, I want to compare Total column value with a constant. If you click "Choose a value", Flow will suggest you fields from your list (which was selected as a trigger):
In my case, that's "Total" column. Add "is less or equal to" condition, type in a number and that's it:
Implement If-Else logic
The only remaining things are our condition branches. Add an action in "Yes" branch and search for "sharepoint update". We're going to update current SharePoint item with some values. Select "Update item":
Initialize Site Address, List Name and Id using Dynamic content. MS flow will suggest you values based on your selected list. I want to update only "Status" field, however, MS Flow shows all fields for me. You can initialize all required fields with the same values using Dynamic content selector. You can leave empty all not required fields and they will not be updated. As a result, you will have something like this:
That's almost it! Now duplicate the same for "No" path and set Status to "Under review". Save the flow and you're good to go.
In your SharePoint list add an item and check that "Status" field has correct values:
You can make this flow smarter and further extend it with approval process if "Total, $" is more than 100$. If an item was automatically approved, you can send an email to the author saying that it was approved. A lot of possibilities :)
You see, it wasn't so difficult. That's the good thing about MS Flow that everything is pretty intuitive and easy to set up. However, it's true for simple to medium solutions. In an advanced scenario, it might be really difficult to figure out how to solve a concrete issue.
If you want to learn more, check out MS Flow resources - divided by difficulty level. Also Online MS Flow conference was at the beginning of December 2018. A lot of very cool presentations from leading MS Flow experts. Check out this playlist on youtube with all presentations recorded.