Think Dynamic, Do Dynamic Microsoft Dynamic CE | Powerapps || Dynamic CRM || Power Apps || Power Platform

Saturday, 23 March 2024

HOW TO IMPLEMENT JAVASCRIPT CONFIRMATION DIALOGS IN POWER APPS AND DYNAMICS 365

In Power Apps and Dynamics 365, you may need to display a dialog to a user in order to decide which piece of code to run next. We can do this using the command Xrm.Navigation.openConfirmDialog. Let’s look at how to do this from a model-driven Power App.

Go to the app and open the Console in your browser’s developer tools.

The function takes the following parameters:

Xrm.Navigation.openConfirmDialog(confirmStrings,confirmOptions).then(successCallback,errorCallback)
Let’s start with a simple example.var confirmStrings = { text:"Are you sure you want to continue?", title:"Confirm" }; Xrm.Navigation.openConfirmDialog(confirmStrings, null).then( function (success) { if (success.confirmed) console.log("OK"); else console.log("Not OK"); });

In this case, we are opening a Dialog with 2 buttons, OK and Cancel:

We also have a title, Confirm, and a message “Are you sure you want to continue?”. On clicking OK:

We see the code drops into the “success.confirmed”. In a real example we would write code to do something more meaningful rather than just write out to the console:


No comments:

Post a Comment

Popular Posts

Featured post

Understanding Dataverse MCP vs Power Apps MCP – Quick Review

  Understanding Dataverse MCP vs Power Apps MCP – Quick Review Model Context Protocol (MCP) has quickly become one of the hottest topics in ...

Post Top Ad

Your Ad Spot

Pages

SoraTemplates

Best Free and Premium Blogger Templates Provider.

Buy This Template