Today Microsoft released custom Power Fx functions to support reusable code within Power Automate. In this post how to create and use these custom functions.
Create a Custom Function
Table of Contents
To create your custom functions you will have to create a solution first. Once the solution has been created you can select within Automation -> Function the right option to add the function.

Now comes the toughest part.

Create a SubString Function
As you might know, Power Automate does have a Substring Function. But I needed an easy example for this post.
I’m going to set a standard here first. Naming Custom functions. I’m going to use the prefix fun. This will help us identify the custom functions and hey, Cusotm Functions could become a nice new fun feature to use.

The formula that we create is actually an object that we need to create. so As I created a varResult property as an output property, my object that I generate needs this varResult property as well.
As we type the expression that we want, the intellisense will help us develop our code.

The code I used is:
Left(Right(OriginalText, Len(OriginalText) - First), Length)
Now, I will have a look at our soluiton. For just the one function, I’ve now got 6 objects added to my solution. Depending on your function definition this could be more or less.

If you want to update your function then edit the one that has been marked as Function in the Type column.
Use the Custom Power Fx function in a Power Automate flow
To call the function in a flow in Power Automate, just add the Perform an unbound action and select the function that we created.


With the above configuration of my unbound action, I’m now getting the result back that we expect.

So now we can find the result in the varResult shows the substring.
Discover more from SharePains
Subscribe to get the latest posts sent to your email.
Hi Pieter, thanks for sharing. Is this preview feature or GA? Can you include the reference to the original post of MS?
It is still in preview at the moment.
this sounds promising at least, no support for objects=records or arrays yet and cannot be used as “native” powerFX extensions (as a function as part of powerFX expression) though, if I get that right …
This feature is still in preview, so I’m sure there will be further enhancements to be made.