Trigger an instant flow from a model-driven app
Tags: powerplatform, powerapps, powerautomate, dynamics365
Published: 2022-03-12 05:37:56

In this [article](https://dev.to/diskdrive/trigger-an-instant-flow-from-a-canvas-app-simple-example-5f1h), I demonstrated how to trigger an instant flow from a canvas app, now I will demonstrate the same but in a model driven app.

#The Flow button

In a model driven app, there is a Flows button on the details page that allows you to run adhoc commands on the current record. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t85rfh1g2g4gv05dwzu1.png)

It's a little bit confusing because they use the word "Flow" but there's actually two ways to create these "flows". The first is the old fashioned way using on-demand workflows which you can do by just ticking the "As an on-demand process" in any clasic workflow.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9uk06iy4gwsi2zhta0gb.png)
 
The other method is by creating an instant flow in Power Automate and this article is will explain how.

#Scenario

As a simple example to demonstrate the concept, what I'd like to do is create a button to allow me to email the details of a Lead to a hard-coded email address.

#Create the Instant Flow in a solution

Don't click the "Create a flow" button cause that will create a personal flow. We want the flow in a solution so that we can exercise good [ALM](https://dev.to/diskdrive/series/15744) practices.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95mlm2prna991nyjusgb.png)

Select the "When a row is selected" trigger. This is in the old Dataverse (legacy) connector. At the time of this writing, the new connector doesn't have this trigger yet.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0069eh8b0zttr95oej6.png)

Your Environment should be "Default" and under Table, select the record type. For this example, I've selected "Leads".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmc3einwe58qina3khht.png)
 
#Adding inputs

You can feed information into the instant flow by clicking "Add an input" - here I've added a field to enter extra info about the lead.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/293xbzvdbb2vco171bmx.png)
 

#Adding the Email action

Select the Office 365 Outlook connector and Send an email (v2) action.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytfowkcl6w8rdrn4ver7.png)

Fill in the email as you wish.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdjlts9dgzn5iq86qnos.png)

Once this is done, you should save the flow and publish the solution.

#Executing the instant flow

To execute the flow, simply navigate to the Lead that you want. It should now appear under "Flow".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8uw0e9kd9mwehohijkv.png)

As we asked for extra input, it'll prompt for this.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxxxiwga1r64htr9rjqo.png)
 

#Conclusion

Below is the email I get once the flow is executed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3m9qjrzeoljlc1eng9ou.png)

Instant flows allows developers to easily use the features of Power Automate to add extra functionality to their model driven apps.