Is Power Automate Low Code or Now Code, that is an interesting question, and its somewhere in the middle. Its probably closer to no code, as it is definitely possible to create flows that just use the drag and drop ui and input configs. But expressions mucky the water a little, as they are code, but not real code, or are they?
Expressions are incredibly powerful and something that new developers often do not use enough, just like Excel can be used without formulas, would you really want to?
There are a couple of key things to know about when using expressions:
- What expressions are there
- When to use them
- Quick tips
1. What expressions are there
Power FX is the 'language' of the Power Platform, but not for Power Automate. If you didn't already know, Power Automate is actually a Azure Logic App dressed up in a nice suit. The schemas are Logic Apps, the run engine is a Logic App, the connectors by defualt work on both, and guess what, expressions are Logic App expressions.
So if you want a full list of expressions you have to look for Logic App expressions.
They may have added Power Automate to the title, but the url path tells it all π
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference
So if you want to find this, google logic app expressions.
There are as of now (October 2024) 143 expressions, split into 10 sections
- String
- Collection
- Logical Comparison
- Conversion
- Data conversions/Math
- Date time
- Referencing
- Workflow
- URI parsing
- Manipulation
and in most cases there will be an expression for exactly what you need. The best ways to find the right one is
- Use the office MS Learn Page](https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference)
- Power DevBox quick list here
- This funky excel file I created
- The UI
The UI will list all expressions and provide simple descriptions.
2. When to use them
Trick question, the answer is always π
The reason is using expressions instead of actions its the key to good flow design. Although there are readability benefits to using actions, using expressions improves performance and saves api calls (which is becoming more important as time goes on).
Some common examples are:
Conditions
Action
Most common one I see, condition actions are good for different logic but expressions should be used for variables.
Time
utcNow() is such a simple expression I have no idea why the Current Time action exists.
Action
Add Time
Another really simple expression, along with addMonths(), addDays(), addHours(), addSeconds(), addToTime(), getPastTime(), getFutureTime().
Action
Format Number
formatNumber() does exactly the same as the action, so again no idea why the action exists.
Action
3. Quick tips
Under the hood the way Power Automate knows the input is a expression and not a string is it wraps it in @{}. The @ indicates an expression, and the } the end. This means you cant have a string with just @, you have to escape it with itself (@@), this is normally automatically done by the ui.
This is why you cant just type an expression in, but have to go through the expression menu, because if you do it escapes the @.
But you can copy and paste an expression in, so anything complex with multiple nested expressions is easier in a text editor:
While talking about copying, copying expressions between actions can be temperamental, with sometimes it just copying the label. To get around this you can peak the code and copy the expression from there:
The peak code is also great for when you want to use an expression to set a input, as the ui often shows display names but inputs a guid.
As an example check out this Get Items, it looks like the List Name is 'Test list' but if you used an expression that set the list by its display name it wouldn't work. If you peak the code you will see why, as the actual input (named table in the code) is the list guid, with the ui showing the display name to make it easier to select.
As you can see expressions give Power Automate its real Power, and its something you should definitely invest learning in.
Top comments (3)
I see in your example, you use VS Code to edit. I set the language to Python to get bracket highlighting and matching (although others do this as well). Is there a better one you'd recommend?
Wouldn't it be lovely if MS would either do this natively in the flow editor, or release a flow language editor in VS Code.
To be honest I normally don't set it and leave it as text, but when I do its normally json for similar reasons you do. 100% with you, every time I give feedback to Microsoft I ask for code editor, in meantime I use a Chrome ext (see this dev.to/wyattdave/creating-a-power-...). There is a Logic App Vs code extension that is supposed to give proper intelisense but I could never get it to appear in my language list.
You might have to update this post soon after ignite updates :-D