In my last post I discussed how leveraging workflows capability in O365 is a way to maximize the benefits of O365. And I demonstrated a basic workflow built inside SharePoint Online.  This post will continue that theme and show a workflow built using Microsoft Flow.

Flow is Microsoft’s latest iteration of workflow for O365. It aims to make workflows easier to design and more accessible for the average O365 user.  Flow is more oriented to the individual than to the organization. But that doesn’t mean that Flow is not used at the organization level. You have to give a bit of thought up front to what you are trying to do

What I wanted to do was to set up a workflow that captured information from incoming emails. I wanted to place the email attachment in a SharePoint Online library.  From there other things would come into play but the big issue was capturing the attachment.  In the past, you could set up a mail-enabled list or library that would perform this task.  That feature is no longer available in SharePoint Online. So you have to go about it a different way and Flow provides a way to do it!

The Scenario

We have a credit memo system in place that mirrors that of many other businesses out there.  We have a good old-fashioned three part paper form. The problem is that paper takes time to get from point A to Point B. Customers don’t see their credits in a timely fashion.  We hit upon the idea of having our staff take photo’s of credit memos. They send the photo in to accounting so that the process can kick off in a timely fashion.  Problem is emailing the photo’s would become a mess as email is a messy medium to manage.  I hit upon the idea of having a SharePoint library set up to hold the photo’s. They are tagged with appropriate information and workflows can run based on that info.

The Solution

As I mentioned earlier, Flow has lots of pre-built “actions” templates available. One of those is a Flow to save information from an email into SharePoint.  I decided to see if I could leverage that template to make things work for us.

The first thing I had to do was understand that Flow is tied to individuals rather than the organization. It is best to set up an O365 user account to handle Flows that are organization oriented.  It is a best practice to NOT use “real” user accounts for organizational transactions. Use a specific “non-user” account instead.  I created an account for situations such as this named spdistro.

As alias, creditmemo@, was assigned to the account. I then set up an Outlook rule inside the account (within O365, not in a Outlook client on a PC). The rule scans all incoming email for Subject lines that begin with the letters “CM”. It moves those emails to a folder named CreditMemo.  (I originally wanted to scan inbound emails to the account tagged with TO: to creditmemo@. But Exchange Online is too smart. It immediately performs the transformation to the base account spdistro@).  Using aliases makes it simple to use the same base account for may different scenarios. I could do something similar for expense reports and use expensereport@ as an alias.

Here is the account and rule config:

image

And the Inbox and sweep rule:

image

Any inbound email that hits this account and has CM as its first letters in the Subject line will be moved to the CreditMemo folder.

While still logged to O365 as the spdistro user I opened Flow and went searching for a template, specifically for email templates:

image

The template I wanted is in the screenshot.  Opening the template will cause Flow to ask you questions about accounts used to connect to resources. Once connected, Flow will present the template for you to name and customize:

image

The basic steps are provided by the Flow template and wherever you see an ellipses (…) you can click to open things up further.  As you can see, the Flow logic is as follows:

When a new email is found in the CreditMemos folder:

image

I could have performed the selection logic here as opposed to an Outlook rule which moved my emails into the CreditMemo folder.  I could use functions here to further refine selection if required.

image

For each attachment on the email Flow will save the attached photo as a file named CMXXXXX.jpeg in the SharePoint Online library noted.

NOTE: I’m cheating a bit, here.  I know that all files sent to creditmemo@ will be jpeg’s. So I add the file extension as part of the file name. I’m saving the file named for the credit memo as listed in the incoming email Subject line.  I found this flow template by will save the attachment (the Content) with no file extension.  So, in SharePoint there is no preview or auto-opening of the file when you click on it.  Appending the .jpeg extension solves that problem.  I understand that there is a more elegant solution to the problem possible. But it requires some fancy “function” work within the Flow. using Workflow Definition Language that I’m not capable of working out at this point.

I added an additional action to this Flow which is the Delete email piece”:

image

If the Flow actions succeed and the jpeg is created in the SharePoint library the final step in the Flow is to delete the originating email in Outlook.

Before building the Flow I had to create a Library in SharePoint to receive the incoming photo’s.  I wanted to drive some other actions off objects in this library so I added to the standard columns created:

image

As you can see, there are a few pieces of information that help to scope actions. We track specific things including customer info and rep info. We also track two statuses (Pink rec’d, Matching completed).

I also created a series of Views to help set the scope when users are looking for specific items.  And, of course, anything in the library is searchable.

image

You can also see that my updated Flow is creating objects with the .jpeg extension (CM110.jpeg).  The other objects were created by an earlier iteration of the Flow which did not save the file with an extension.

Going forward, staff will receive alerts when objects are added to the library.  I will use the Virto Alerts add-in to generate the alerts as it is a quick and easy way to set this up. I could use SharePoint Designer but Virto Alerts is easier.

So, there is a completed example of a Flow used in an “organizational” context.  I hope this post and my previous post illustrate the benefits of workflows in O365. Leverage the daylights out of your O365 subscription!

A Tale of Two Workflows – Part 2
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *