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.
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.