Using PowerApps to Replace Dialogs in Dynamics 365
Sharing Our Expertise

Our consultants solve challenging business problems and love sharing their knowledge. Tap into our insights and put them to work for you.

Back to Blogs >>

Published on Thursday, January 3, 2019

R.D. Sturgis, Senior Consultant

Beginning in June 2017, dialogs were announced as one of the deprecated features in Dynamics 365 (https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming.) Microsoft recommends that moving forward, CRM Administrators use Business Process Flows (BPF) or Canvas Apps (PowerApps) instead of dialogs for any new development. Eventually, all dialogs will need to be replaced with a BPF or Canvas App. Microsoft provides the following link to help you determine if it is better to use a BPF or Canvas App when developing a new or replacing an old dialog: https://docs.microsoft.com/en-us/flow/replace-dialogs.

This blog will demonstrate how to create a Canvas App in PowerApps to introduce functionality that in the past would have been accomplished by using a dialog. Full disclosure: documenting this process is a bit lengthy with a lot of screenshots, but if you utilize Dialogs currently, you will find it helpful to understand how PowerApps can address the coming changes.

The example that this blog will use is a simple survey that a CRM user would fill out while making a phone call to a customer. 

In the past, a user would launch a dialog by clicking on 'Start Dialog' from the Command Ribbon,

Dynamics 365 PowerApp Dialogs 1

and then click on the corresponding dialog, followed by clicking 'Add':

Dynamics 365 PowerApp Dialogs 2

This would launch a dialog that would act as a wizard to walk the user through a series of questions that would then create a record in CRM when the user clicked Finish.

Dynamics 365 PowerApp Dialogs 3

This same functionality can be achieved using a Canvas App in the Microsoft PowerApps platform.

Here is how the Canvas App would work. From the Account Form, a user would click on a new “Survey” button.

Dynamics 365 PowerApp Dialogs 4

That button would contain JavaScript that called out to the Canvas App and pass the GUID for the Account that is opened. The Canvas App would then pull in information about the Account and display it to the user who could then hit the Begin button to start the survey.

Dynamics 365 PowerApp Dialogs 5

After hitting the Begin button, the user would be presented with the first set of questions:

Dynamics 365 PowerApp Dialogs 6

After filling in their answers, they would hit the Next button to go the second set of questions:

Dynamics 365 PowerApp Dialogs 7

After completing the second set of questions, the user would click the Finish button to submit the answers to Dynamics 365 which would create a record in a new “Survey Response” entity.

Let’s get into the technical details of how to create the Canvas App and launch it from the Survey button on the Account form.

To create the Canvas App, you would log into https://www.office.com and navigate to PowerApps by clicking on the PowerApps icon (This assumes you have the appropriate license to access PowerApps).  You could skip this step by directly logging into: https://web.powerapps.com.

Dynamics 365 PowerApp Dialogs 8

From there, click the + sign to create a “Canvas app from blank”

Dynamics 365 PowerApp Dialogs 9

From the Insert menu, click the down arrow on Forms and then click on Display.  This will be used to display the Account information for the Account that the survey is for.

Dynamics 365 PowerApp Dialogs 10

You will need to connect the form to your data in Dynamics 365. To do that, click on the down arrow and click ‘Add a data source’.

Dynamics 365 PowerApp Dialogs 11

Choose the connection for Dynamics 365:

Dynamics 365 PowerApp Dialogs 12

Type “Account” in the search box to filter the results and then check the box next to Accounts and hit the Connect button:

Dynamics 365 PowerApp Dialogs 13

Your form will then be connected to the Account entity in Dynamics 365. The form will default to having 10 fields from the Account entity displayed. 

Dynamics 365 PowerApp Dialogs 14

We will limit this to the five fields that we want to display by unchecking the check box next to the fields that we do not want to display or by checking the box for the field that we want from the Account entity. The fields can be reordered by clicking on a field and dragging it up or down to the desired position. We will also change the “Snap to columns” setting to 1 so all fields display in a single column.

Dynamics 365 PowerApp Dialogs

The data that is displayed on this form needs to be limited to the Account that the survey is created from. To do that, Click on the Advanced Tab and in the Items box, put the following LookUp command:  LookUp(Accounts,accountid=Param("AccountId"))

Dynamics 365 PowerApp Dialogs 16

This will limit the data to the single account record by using the Account GUID that is passed into the application. How to pass in the Account GUID to the application from the Survey button in Dynamics is covered at the end of this blog.

Next, we will add a title to the form. To do that, we will click on the Label button in the ribbon:

Dynamics 365 PowerApp Dialogs 17

Change the text to Customer Survey for Account and then center the text by clicking on the Home menu option and clicking on the Center option:

Dynamics 365 PowerApp Dialogs 18

The last item for the first page of the application is to add a Begin button to the bottom of the form. Hit the Button icon in the command ribbon and then change the text to Begin.

Our form should now look like this:

Dynamics 365 PowerApp Dialogs 19

Next, create a new screen by clicking on the new screen button in the command ribbon and choosing the “Blank” screen option. Change the name of the new screen to QuestionPage1 and then add two labels and a drop down for three different questions. Add a Back and Next button to the bottom of the new form and a label for “Customer Survey for Account” at the top. When finished, the form should look like this:

Dynamics 365 PowerApp Dialogs 20

QuestionPage1 should have the following property names. These names will be used when submitting the data to Dynamics which is covered later in this blog.

Dynamics 365 PowerApp Dialogs 21

To make the buttons navigate from one page to another, select the button and then click on the Action menu and set the Navigate properties to the page you want to navigate to and the desired screen transition.

Dynamics 365 PowerApp Dialogs 22

Next, create the last screen of the application by adding another blank screen and renaming it to QuestionPage2. Add a label with the text “Select a date for follow-up phone call” and date control and then a second label with the text “Customer suggestions or comments” and text box control. Finally, add two buttons at the bottom of the form with the text “Back” and “Finish”. The final form should look like this:

Dynamics 365 PowerApp Dialogs 23

When finished, QuestionPage2 should have the following property names:

Dynamics 365 PowerApp Dialogs 23.5

The command for the Finish button is what will be used to create the Survey Response record in Dynamics. The command will use the Patch function to create or update the Survey.

Here is the command for the Finish button:

Patch('Survey Responses_1',Defaults('Survey Responses_1'),{psc_accountnametext:AccountNameValue.Text,psc_question1:Question1QuestionLbl.Text,psc_question1answer:CommunicationDD.Selected.Value,psc_question2:Question2QuestionLbl.Text,psc_question2answer:SatisfactionDD.Selected.Value,psc_question3:Question3QuestionLbl.Text,psc_question3answer:RecommendDD.Selected.Value,psc_question4:FollowUpLabel.Text,psc_question4answer:FollowUpDate.SelectedDate,psc_question5:Question5QuestionLbl.Text,psc_question5answer:CommentsSuggestionText.Text})

And here is what it looks like in the App:

Dynamics 365 PowerApp Dialogs 24

The PowerApp is now complete and ready to be published. To publish the app, click on the File menu then hit Save. After the app saves, you will be presented with a button to Publish the application.

Dynamics 365 PowerApp Dialogs 25

After publishing the application, you will be presented with a button to Share the application. The application must be shared with all members of your Office 365 tenant who will need to access the application.

The last thing that we need to do is call the new application from Dynamics. To do that, use the Ribbon Workbench to add a new Survey button to the command bar of the Account form. The new button should call a JavaScript function called OpenAccountSurvey and pass in the FirstPrimaryItemId to the function. The FirstPrimaryItemId represents the GUID for the Account that the user is viewing when pressing the Survey button.

Dynamics 365 PowerApp Dialogs 26

Below is the code for the OpenAccountSurvey function:

function OpenAccountSurvey(firstPrimaryItemId) {

    try {

        Xrm.Utility.showProgressIndicator("Opening Account Survey");

        var recordId = firstPrimaryItemId.replace("{","").replace("}","").toLowerCase();

        var accountSurveyUrl = "https://web.powerapps.com/webplayer/iframeapp?hideNavBar=true&source=website&appId=/providers/Microsoft.PowerApps/apps/e24ce2b0-cea6-4115-a98c-ca3ac6333333&AccountId=" + recordId;

        Xrm.Utility.closeProgressIndicator();

        var memberIdWindow = window.open(accountSurveyUrl, "Account Survey", "scrollbars=yes,resizable=yes,height=950,width=950");

    } catch (e) {

        Xrm.Utility.closeProgressIndicator();

        console.log("OpenAccountSurvey > catch > error: " + e.message);

    }

}

Note that the accountSurveyUrl uses the GUID for the PowerApp that we are calling (e24ce2b0-cea6-4115-a98c-ca3ac6333333.).  To find the GUID of your PowerApp, go to your list of Apps and then click on the ellipsis then go to Details.

Dynamics 365 PowerApp Dialogs 28

The App ID at the bottom of the screen is the GUID you need to use in your JavaScript:

Dynamics 365 PowerApp Dialogs 28.1

 

PowerApps will continue to evolve and help ensure legacy functionality can be continued and extended. If you utilize Dialogs currently, this tool and process will be helpful towards understanding how PowerApps can be leveraged to help maintain familiar experiences for your users. If you have any questions, please let us know via the contact form below or at: info@psclistens.com.

 

Return to Dynamics 365 eNews


Categories: Dynamics 365,CRM,Dynamics CRM,PowerApps,Canvas Apps

Recommended For You
The combined power of Dynamics 365 for Sales and LinkedIn empowers sellers to find and focus on the right prospects and customers.
View More ...
After years of requests, the Dynamics 365 CRM Opportunity Close entity, form, and dialog are finally configurable.
View More ...
To help tackle the issue of training and user adoption, PSC has recently partnered with ClickLearn to make the tool available to PSC client compa...
View More ...
One of the very first things a Dynamics administrator has to navigate when they start using the latest Unified Client Interface (UCI) is: “Where ...
View More ...