Choice, flow or app code

Power Automate and Power Apps use the same connectors. So do you use a flow or app code? It can be an important choice.

An example app

I’m going to use a simple app that sends out an email when I press a button.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 30

Doesn’t look very interesting, does it?

Well if the aim is to send an email then you might have some options. I see many people create flows that send out an email, but there is no real reason for this.

Run a flow or app code

I could quite easily add an Office365Outlook connection to my app and then add the following code the the onselect property of my button.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 31

The alternative would be to add a flow to the button and you pass parameters into the flow to do all the work.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 32

The first things to ask is what can and what cannot be done within Power Apps code? Most actions available in Power Automate seem to be available within Power Apps.

So now the question is which method do you use? Both methods do have their pros and cons. Things I would consider are:

  1. Simplicity of the solution
  2. Performance
  3. Availability of the connectors
  4. Costs

Simplicity

When I use the SendEmailV2action in Power Apps with the action available in Power Automate, I quite quickly notice that the Advanced settings in flow appear as a separate object. this is the bit between { … } in the below tooltip.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 33

Comparing this line of code to the equivalent Power Automate action, We will find that ll the options are there but using the action is a little easier.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 34

From a simplicity perspective it is of course also helpful to put all your code/actions in one place when possible.

Performance

Performance is always a tricky problem. Performance can be about speeding up your code but it can also be a matter of not letting your users wait for the code to complete.

So if you were to update 100 items in SharePoint you could do this in code when you press a button, and then collect the results back. Or you could click a button and run a flow doing the updates. Or you could press a button and not collect the result of the updates, so that your app can continue to do what it does.

flow or app code, and app code example

You could even consider running the code in a timer so that the user will not notice the time that the code takes to run.

Performance wise running a flow will hardly be any different from running code in Power Apps.

Availability

So are all the connectors available ion Power Apps and Power Automate? I tried the approvals connector and even though the same actions are available. Power Apps doesn’t seems to make it easy to guess what the approvalType is.

So approvals can be one of those things that you may have to use Power Automate for.

Power Automate flow or app code in Power apps? Microsoft Office 365 image 37

It would be really useful though if approval steps could be created directly from a Power App. And even the documentation mentioned earlier is not clear about how we can supply the approvalType.

So if you have figured out how to do this, please do let me know in a comment below.

Costs

The 4th consideration I would like to make is cost. If you run a premium feature from an app you will have to make sure that either your app or your user is licensed to use premium features.

And yes if you call a flow directly from your power app then there is still that need to use premium licences and unless you disconnect the user’s activity within the Power App from the activities in a flow. you will not be able to avoid these additional costs.

So which one wins?

The choice between flow or app code is simple. Availability of connectors is the first thing to look at. What isn’t possible isn’t possible.

From a simplicity perspective, it probably more depends on who develops the solution. It is not just about familiarity with Power Apps or Flow. Personally, I might prefer Power Automate while others prefer Power Apps.

But the important consideration for me is however to keep all code nicely together when possible.

So attempt to put your flows in Power Apps unless your app cannot be made to perform or Power apps doesn’t support a feature used within the connector.

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

2 thoughts on “Power Automate flow or app code in Power apps?”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.