Run Power Automate From Command Button

Requirement

Modern business applications demand automation, whether it is a heavy data driven model drive app or light weight canvas app. Microsoft Power Automate makes it easy to streamline workflows directly within the Microsoft ecosystem. Let’s say we want to run Power Automate on demand for some particular record just like we can run classical workflow by setting it run as on demand option. For Power automate we can use “When a row is selected” trigger, but the problem with this trigger is that user need to respond to dialog first and after that it will start. In this post I am going to discuss how we can implement workaround for that and instead of using “When a row is selected” trigger we can use “When a row is added, modified or deleted” trigger using command button.

Details

Sometimes we have option to use logic directly on existing field update but sometimes we can’t use any existing field directly to trigger Power Automate so to run on demand Power Automate, I am going to add a flag (two options) field and then going to add command button from where I will update this flag which will run Power Automate so let’s see.

Let’s say I added a two option set field “Is Approval Required” now I want to update this field from command button using Power Fx. Open Model driven app in editor mode and click on more options next to the entity view for example I want to add command button on account entity form so I selected Edit command bar.

In Next dialog select Main form. Next click on New option and drag command button to command bar and change set title as required.

Click on Open Formula bar and use following formula:

Patch(Accounts,Self.Selected.Item,{‘Is Approval Required’:true})

Here Accounts is name of the table, we want to edit current record and next is the field name which want to set to true. Sometimes you will get error as it won’t recognize your field, after adding formula make sure to click on “Open component library” and there click on Save and Publish your library.

Now we can place field on the form (For testing, otherwise we don’t need to put this field on form) open any existing record and when by default this will be blank but when we will click on Send RFP button it will set value of this field to Yes.

Now we can setup Power Automate to trigger on this field change, make sure to add filter to run only when value of this field is set to true for example for me it will be him_isapprovalrequired eq true.

Also make sure to set this flag to false in first action so in case we want to re-send RFP.

Summary

Triggering Power Automate flows from a command button in a model-driven app is a powerful way to empower users with automation directly in context. It simplifies tasks, reduces clicks, and ensures better data consistency. Whether you’re updating records, sending notifications, or integrating with external systems — command-triggered flows enhance user productivity and system efficiency.

Leave a Reply

Your email address will not be published. Required fields are marked *