I’m happy to announce I will be working on a Microsoft Flow series titled Express Yourself: Building Expressions with Microsoft Flow. The first part of the series, which is this post, is dedicated to introduce the audience to Expressions in Microsoft Flow. Without further ado, here is the first post of the series. Enjoy!
Microsoft Flow is a cloud-based service that makes it practical and simple for line-of-business users to build workflows that automate time-consuming business tasks and processes across applications and services. It is part of a powerful and adaptable business application platform that includes PowerApps, the Common Data Service, Dynamics 365, and Office 365. Out of the box, Microsoft Flow connects to more than 100 data sources and services such as SharePoint, Dynamics 365, OneDrive, Dropbox, Salesforce, SQL Server, Trello, Twitter, and Customer APIs, among others. At the time of this writing, there are 212 data sources and services available in Flow.
What Are Expressions
All the data sources and services Microsoft Flow can connect to come with a set of triggers and actions, but there are times where users just need to do some basic operations like getting the current date and time, convert a string from lowercase to uppercase, add numbers, or retrieve the number of elements in an array or string. This is all possible by using Expressions. Expressions can be defined as a set of functions that can be used to do so many things such as manipulating strings, convert data types, retrieve and manipulate date and time, and perform math functions. For these functions, Microsoft Flow leverages the Workflow Definition Language used by Azure Logic Apps. There is a section dedicated to providing extensive details on the Expression types and their respective functions.
Where Expressions Can Be Used
There are times in which data needs to be manipulated to achieve a desire outcome within an action. Expressions can help with that. For example, an attachment is retrieved from an email and it needs to be saved in a SharePoint library or OneDrive. The user may want to save the file with a different file name, which may include the current date and some other naming convention they have in place. In here, the user can build an Expression to concatenate the actual file name with the current date. This Expression can be built directly in the desired field.
When a Flow is created, there will be times when a Condition may be used to compare a single value with another value. But there will other times when a Condition may need to compare multiple values. To compare a single value, you can edit the Condition in Basic mode. You first select the field to compare, then select the logical operator, and then you enter the value to compare with the field. Now, when you need to compare multiple values, you must edit the Condition in Advanced mode. In Advanced mode, you can use a combination of logical operators such as and, or, equals, greater, less, greaterOrEquals, lessOrEquals, empty, not, and if.
When working with Expressions in Flow, we must keep in mind that there are certain limitations within the platform. These limitations are the number of characters an Expression can evaluate and the number of characters allowed in an Expression.
Expression Evaluation Limit
A Flow Expression can evaluate up to 131,072 characters. I know this number is far-fetched, but it is important to remember in the event we need to have Flow process a large chunk of text from a string.
Max Character Per Expression
When building an Expression, the maximum number of characters allowed is 8,192 characters. One may wonder how it would possible to build such a large expression, but when you start to build complex expressions, they can get considerably large.
The list below contains all the functions that can be used in Flow to build Expressions.
The String functions are used to manipulate strings. You can concatenate strings, replace a string within a given string, and convert strings to either upper or lowercase, among others.
The Collection functions operate over collections and generally apply to Arrays, Strings, and sometimes Dictionaries.
As the name implies, the Logical functions are used to evaluate any type of logic within Flow. These functions are extremely useful inside conditions.
The Conversion functions are used to convert data between each of the native types in the language, such as String, Integer, Float, Boolean, Arrays, Dictionaries, and Forms.
The Math functions can be used to do calculations for either type of numbers: integers and floats. You can perform addition, subtraction, multiplication, and division. Additionally, you can retrieve the remainder after dividing two numbers, or generate a random integer within a specified range.
Date and Time Functions
The Date and Time functions can be used to retrieve current date and time. Additionally, they can be used to format date and time, convert time zones, add days, and get future and past time, among others.
These functions help you get information about the workflow itself at run time, such as name, type, id, location, and run.
URI Parsing Functions
The URI Parsing functions were recently introduced and they provide the ability to parse URLs in your flows. From a given URL, you can select hostname, path, port, scheme, and query segments.
These functions apply to XML and JSON objects. Some of these functions are used to return the first non-null object passed in an argument, while some others are used to add, set, or remove properties to an object.
In the coming weeks, I will be working on the subsequent posts in the series. I will try to have as many examples as possible so you can understand the Expressions better. As always, if you have any questions or would like to provide feedback, please do not hesitate to reach to me via Twitter or LinkedIn.
Thank you for reading.
Fausto Capellan, Jr
Photo by Element5 Digital on Unsplash
4 thoughts on “Express Yourself: Building Expressions with Microsoft Flow”
Be good to see common expressions covered and an understanding of some other their uses in real world scenarios.
Thank you so much for your reply. One of the goals of this series is to provide a better understanding of expressions and to provide real world scenarios for users of all levels. I will be working close with the community on this.
[…] Fausto Capellan Jr – https://faustocapellan.com/2018/03/02/express-yourself-building-expressions-with-microsoft-flow/ […]
[…] Building Expressions with Microsoft Flow […]