Dev Notes

Notes on Development with Microsoft Technologies

Using Workflow Definition Language with Microsoft Flow

Leave a comment

Microsoft Flow is a very powerful product and it is getting better all the time. However, I wanted to build a flow that would automatically create a date in the future when creating tasks on my Trello board. There isn’t anything built into Microsoft Flow Actions that does this (at the time of this blog post), but it can be done using Microsoft’s Workflow Definition Language.

The workflow definition language is used when building Azure Logic Apps. Since Microsoft Flow makes use of Logic Apps, we can leverage this to do the calculation. The key to using these functions is understanding how to pass them into your flow actions. This is where I had my biggest disconnect, so I will share what I’ve learned to this point. I’m sure there are better ways to do these steps, but I’m just at the beginning of discovering how.

First, I logged into Microsoft Flow and created a new flow. When working on solving new problems, my goal is to build something very simple that solves my immediate problem and then back up to include it in the final solution. This flow is the simple solution, so I called it Simple Time Calculation Testing. The idea is to send a notification with an updated (and formatted) time 15 days from the time the flow ran.

To start, I added a recurrence trigger set to run every 15 minutes. The frequency doesn’t really matter as I will typically run it each time I want to test it.

I read on the Flow Community Board that the Data – Compose operation can be used to execute the workflow definition language formulas. Using this information, I added a Data – Compose action to my flow and set it to use add 15 days to the current time. The trick here is to use a single @ and enclose the entire function call in quotes.

"@formatDateTime(adddays(utcnow(),15),'D')"

The formula starts with a call to formatDateTime. Notice the second formula, adddays, is not preceeded by @, nor is the third function utcnow. This call will get the current date and time using the utcnow function. It will then have 15 days added to it by the addays function. Finally, it is formatted into the long date format by using the second parameter of the formatDateTime function.

In the image above, the flow has already run so the quotes do not appear. When the block was added, it originally had the quotation marks.

Now we have a flow that runs every 15 minutes and gets the current time formatted in a long date. To see the date, I added a notification block to send an email of the contents. The final flow appears below.

Testing the flow, I get the expected result in an email notification.


In summary, as you can see here it is possible to make use of the Workflow Definition Language from Logic Apps within your Microsoft Flows. The challenge I’ve found is just simply knowing what you CAN do as the documentation leaves you with the impression that you are limited to what is provided in the available triggers and actions. As you can see here, Microsoft Flow does have some hidden capabilities that you can leverage as a developer within your organization.

Advertisements

Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s