Have you ever wondered why the Expression box in Microsoft Flow is so small? It is because Flow is a low code product and low code means that we don’t need much code. Often a one liner can do the job.
Sometimes it is the small things in Microsoft Flow that make it difficult to get the job done! In this post I’m looking at 10 one-line expressions that can help. Most of these on liners will fit in that small expression box.
Expression 1 – Get your workflow run URL
This is one of my favourites that couldn’t miss from this list.
concat(‘https://unitedkingdom.flow.microsoft.com/manage/environments/’, outputs(‘Compose’)[‘tags’][‘environmentName’], ‘/flows/’, outputs(‘Compose’)[‘name’], ‘/runs/’, outputs(‘Compose’)[‘run’][‘name’])
For more details see my post about finding your run Url.
Expression 2 – Format your dates
Formatting dates is easy in Flow
Also see How to find your overdue tasks?
Expression 3 – Get the last X characters from a text
Getting the first X characters is easy using the substring function. The last X characters is slightly harder especially if you don’t know how long the text is. The following expression is your answer:
substring(outputs('Compose'), sub(length(outputs('Compose')), 4),4)
Expression 4 – Get that space into a variable
When you set a variable to a space Flow will tell you that the value is empty. the following expression will help you set a variable to a space.
Expression 5 – Fix those failing switches
When you use switches in Flow and the switch value is sometimes not set you will find that your flow will fail. If you use the coalesce function you can make sure that you always get a value from a variable or action output. Even if the variable or output isn’t set.
For more information see Improve your switches.
Expression 6 – Compare those texts
How often do you need to check the value of a text variable or output. A while back I was looking at the extensions of a file name
The below expression returned false:
In the above example I used variables, but for simplicity sake I’m using hard coded strings. To solve my problems I used the toUpper fuction:
Expression 7 – Have you got any great expressions?
The last expression spot in this post is still available. Have you used any great expressions? Please leave you useful one liners in the comments below.