Flow: WDL – Use Multiple Functions to Make Interesting Expressions

In this post, we will once again reference back to part 8 – Call O365 Roadmap Web Service Weekly Digest where we have sent Microsoft 365 Roadmap updates via email.

The email body contains some interesting expressions and use of several nested functions using WDL, Workflow Definition Language.

A full reference on WDL can be found at this link.

Here is the section of the Flow that I am referring to:

Firstly, let's break down the expressions in the second row of the table, the one that looks like this:

And here is the code …

The formatDateTime function has a default format of yyyy-MM-ddTHH:mm:ss:fffffffK. This is the universal ISO 8601 specification.

Would you like to buy Alan a coffee?

Visit the AlanPs1 Ko-fi page

formatDateTime('<timestamp>', '<format>'?)

In order to return only 'December 7' I have used format 'M'.

formatDateTime(item()?['publishDate'], 'M')

The first category is targeted below, we are passing in [0] to get the first item in that array.

We are using the items function but targeting 1 item so it doesn't output a loop or multiple values.

items('<loopName>')

items('Compose_the_links_for_each_blog_post')['categories'][0]

Each of the 4 expressions below are identical, apart from looking for Q1, Q2, Q3 or Q4 in the summary and replacing that summary with only Q1, Q2, Q3 or Q4.

This is a work around as the roadmap doesn't actually publish the release date to the XML RSS Feed.

We are using the if function, the contains function and the replace function to essentially do what I described above,  replace that summary with only Q1, Q2, Q3 or Q4.

if(<expression>, <valueIfTrue>, <valueIfFalse>)

contains('<collection>', '<value>')

replace('<text>', '<oldText>', '<newText>')

Nesting functions in this way is the key to filtering and formatting your data with Flow.

if (contains(items('Compose_the_links_for_each_blog_post')?['summary'],'Q1'),replace(items('Compose_the_links_for_each_blog_post')?['summary'], items('Compose_the_links_for_each_blog_post')?['summary'], 'Q1' ) ,null)

if (contains(items('Compose_the_links_for_each_blog_post')?['summary'],'Q2'),replace(items('Compose_the_links_for_each_blog_post')?['summary'], items('Compose_the_links_for_each_blog_post')?['summary'], 'Q2' ) ,null)

if (contains(items('Compose_the_links_for_each_blog_post')?['summary'],'Q3'),replace(items('Compose_the_links_for_each_blog_post')?['summary'], items('Compose_the_links_for_each_blog_post')?['summary'], 'Q3' ) ,null)

if (contains(items('Compose_the_links_for_each_blog_post')?['summary'],'Q4'),replace(items('Compose_the_links_for_each_blog_post')?['summary'], items('Compose_the_links_for_each_blog_post')?['summary'], 'Q4' ) ,null)

Now let's move on to row 2 where to be frank, there is anything special going on so here is the image and code below. It just uses dynamic content.

items('Compose_the_links_for_each_blog_post')?['summary'])

Row 3 is just there to create some spacing and is an empty row.

Row 4 is a little more interesting

I will skip the Feed ID (dynamic content) and move on to the other 7 expressions, as below:

As mentioned earlier in this post, you can work with dates using formatDateTime and for this I have opted for a UK date format and applying that to publishDate.

formatDateTime(item()?['publishDate'], 'dd/MM/yyyy')

Applying the below to updatedOn.

formatDateTime(item()?['updatedOn'], 'dd/MM/yyyy')

Below gets you the second item in the categories array

item()?['categories']?[1]

Now to keep things neat and to allow me to show a visual separator between each category, or tag as they are referred to I have used the concat function to add the bullet. This works well as if the value is null, you will not see a lonely bullet.

concat('<text1>', '<text2>', …)

if(not(equals(item()?['categories']?[2], null)), concat('• ', item()?['categories']?[2]), ' ')

if(not(equals(item()?['categories']?[3], null)), concat('• ', item()?['categories']?[3]), ' ')

if(not(equals(item()?['categories']?[4], null)), concat('• ', item()?['categories']?[4]), ' ')

if(not(equals(item()?['categories']?[5], null)), concat('• ', item()?['categories']?[5]), ' ')

The reason the above has been implemented in this way is that I have seen as many as 5 tags and as few as none. So this approach handles this and what the heck. Isn't it handy to be able to either add a prefix or a suffix to a dynamic value or expression.

So, give it all a try and a great place to start would be to follow the 8 part series called Create Office 365 Alerts Shared Mailbox from APIs. The series is for everyone and should help you on your journey with Microsoft |Flow.

Alan

Do you need assistance building this Flow?

Visit the Get Help section of the Power Automate Community