In my last post, I gave an introduction on how Microsoft Flow can help save time and money by automating Office tasks and how end users can easily create new workflows. However, the power that flow brings when using Dynamics 365 is something that deserves to a much closer look.
First, let’s look at a simple flow that is incredibly useful when in business meetings or at client sites to do of the most important routine tasks of Dynamics CRM, entering a new contact. Contacts are often collected in writing, on a smart phone, or with business cards, and then later entered in the CRM. This, of course, has some small risks. A business card might get misplaced or the ink smeared on a phone number. One could put them in a laptop, but wireless internet access on a client site isn’t a given.
Flow offers a much simpler approach, a simple button on your smartphone to bring up a simple list of 5 inputs to enter new contact information that then automatically creates a new contact in Dynamics on the fly. The Microsoft Flow site has a template for this called “Create a new contact in Dynamics CRM” and consists of a trigger and two actions. The trigger looks like this:
These can be customized of course. For example, you may want to have another input for the business name, but in its initial form, it has all the minimal information needed for a business contact. This trigger can be added as a button on your smartphone after installing the Flow mobile application, which can be obtained from the links on this page: https://docs.microsoft.com/en-us/flow/mobile-create-flow
After the trigger, the template has two action steps defined. The first takes the inputs from the trigger and generates the Dynamics CRM contact entity.
The final step is a return notification that the contact was created. This is important to have, as it gives confirmation that the workflow completed successfully.
That’s all there is to it. Now, we’ll look at something a bit more complex, but otherwise much more difficult to do without Flow. Social media is not only a great way companies can get messages out, but also a medium from which to gather leads. One good example would be business leaders and managers sending positive tweets to a Twitter hashtag about a new business product from a line your company sells technical support on, or related connecting products. However, as those who use Twitter should be aware, the web interface for Twitter is quite slow and painful when it comes to scrolling through the historical postings to a hashtag. Flow has connectors on just about every social media platform out there, so let’s walk through a workflow that lets you automatically generate leads from Twitter hashtag and word searches.
The first step is a trigger, and as with nearly all manually triggered actions, it starts with the manual trigger button. The Twitter connector has a search input step that goes directly to the Twitter API and outputs the results of the search.
For the next step, we’ll look at something new, a looping operation step called “Apply to each”. Many connector actions can output multiple results for which each must be individually processed. In this case the Twitter search action is producing a list of tweet bodies matching the search text. Apply to each will perform the actions contained within each output of the prior action. Here we have two steps. The first gets the user name from the TweetedBy field of the tweet body.
This may look confusing because the term “Body” for a message is usually associated with the content of an email. In the case for Twitter, the body contains not only the message, has all the fields of the tweet as well. The Twitter user’s tag name isn’t something to use for the contact information, we want the user name. This can be done using the Twitter Get User action which will output the user name from the TweetedBy field.
Following the Twitter Get User is the same Dynamics action we mentioned earlier to create a new contact, only in this case it should be done as a leads entity. These steps repeat until the Apply to each has looped through every tweet from the search.
Finally, we wrap it up with a notification. You’ll see this a lot with most templates for the simple reason that it’s a fast and easy way to know that the action was completed successfully. Without a notification, the only way a user can check if their workflow has finished successfully would be to connect the flow website and check the history. This is time consuming and not something you want to have to keep doing from a mobile device.
We’ve looked at workflows from outside Dynamics, but what about from inside Dynamics? This is where PowerApps comes into play. PowerApps is a system that links organization data from Dynamics or SharePoint into custom application, Power BI dashboards, and work flows. While it doesn’t require any knowledge of programming languages, it does require knowledge of the more advanced aspects of Dynamics in terms of how data is managed with fields and entities. If you don’t have a Dynamics Partner to help with creating more complex flow integration, I would strongly recommend seeking one out. Dynamics Partners like KTL Solutions can save you time and hassle by providing the technical knowledge to create workflow integrations customized to your needs.
For this example, I’ll put together a flow that uses fields from PowerApps that automatically creates an approval email for generating a new case in Dynamics if the approval email comes back approved. Once done, the flow can be added into Dynamics by a user with sufficient rights.
First, PowerApps is added as the trigger. One difference you’ll notice is that there are no setup options. Outputs fields are generated automatically as needed and when started from Dynamics, those fields are populated from there programmatically or with user prompts.
The next step is “Start an approval”. While you might assume this to be an Outlook action, approvals is actually a separate connector type and can be configured to use services such as Zendesk, Salesforce, or Gmail.
Here I’ve added a title and assignment using dynamic content fields. These were added by clicking the “Add dynamic content” button which will show a list under “PowerApps” like this:
It’s important to note that since this example comes from a template that was previously added to Dynamics, it has the field names and descriptions that were used to prompt the user. If you are creating this flow from scratch, you’ll need to click “Ask in PowerApps” to generate a new PowerApps field with a fixed automatic name that can be changed to the actual Dynamics fields when the flow is added to Dynamics.
Following the “Start an approval” step there needs to be a check to see if the approval came back as approved. This is done using a condition step like this:
The “Response” box is a dynamic field added by clicking the “Add dynamic content” button which displays the list of fields output from an approval email. If you are unsure of which fields to use or what they return, documentation is available online with information on the fields of connectors. The URL for the documentation home page is here: here: https://docs.microsoft.com/en-us/powerapps/
Add condition steps will result in a branch of two possible actions. One for if the condition is met, and the other if the condition is not met. Both of which appear as containers in which one or more action steps can be added, which only occur for that condition. In this case, we want a new case record to be created if the approval comes back as approved, and so a “create a new record” action needs to be added to the “if yes” condition box like this:
The “if no” branch is left empty as nothing is being created or done if the approval comes back rejected.
This is a just a small example of the many possibilities with creating Flows using Dynamics. Dozens of connectors now exist to create workflows with many other database, messaging, and social media platforms and systems. The complete list of connectors is available at https://us.flow.microsoft.com/en-us/connectors/. The large numbers of connectors and fields can be overwhelming and so I recommend you engage a Dynamics Partner like KTL Solutions to help create complex workflows to suit your needs.