{No code} Confirm Dialog onclick of command button in Model Driven Apps/ Dynamics 365

Hello everyone and welcome to my blog. In today’s blog I shall walk you through a new function to show a confirm dialog when a command button is clicked in Model driven apps or Dynamics 365 Apps. And guess what – without writing a single line of code!

Without further ado let’s get started. For this example I have used out of box Account table.

In the account table, I have a field – “Credit Limit Approved“. It’s a Yes/ No field.

I have a button – “Approve Credit Limit” on the account form. The requirement is – when this button is clicked, the user should be displayed a confirmation dialog. If the user proceeds with confirmation, the column value should be updated to Yes.

Traditionally we use the Xrm API to achieve this. We shall use Xrm.Navigation.openConfirmDialog to show the confirmation dialog to the user.

But you no longer need to do this. Power Fx now has a Confirm function which works in Model-driven apps. Essentially it means it will work for your Dynamics 365 Apps too. And without writing those complex scripts.

Below is the formula OnSelect of the button. I am using the Power Fx command designer to edit this button.

If(Confirm("Approve Credit Limit?", 
                {Title: "Credit Limit Confirmation", ConfirmButton: "OK", CancelButton: "Cancel"}
           ),
    Patch(Accounts, Self.Selected.Item,{'Credit Limit Approved': true})
);

I save and publish the changes. Now when I open the record and click on the button, I am able to see the confirmation dialog. Check for the below video.

Wonderful isn’t it? Something which needed quite a few lines of code can now be accomplished with just Power Fx formulas.

Hope you liked this post. If this post has helped, you can buy me a coffee. Links on right pane.

For similar topics on Microsoft.NET and Power Platform, subscribe to my blog using the Subscribe option on right pane.

You will also like the below posts.

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading