Thanks to the Power Platform, the options we have to extend Dynamics 365 Finance and Operations without writing code have multiplied. In previous articles we saw how we could take advantage of Power Automate flows to do so, and this time, we will focus on the different ways we have to embed Power Apps canvas applications into FnO forms.
Table of Contents
Preparing the application to interact with F&O
For this example, we have prepared a canvas application that will show the total amount of sales made to a particular customer, grouped by the status of the lines, so we will have the total amount invoiced, delivered, backorder and canceled. The ERP data can be used within the application through the use of Virtual Entities or Virtual Tables. You can get more details on how to configure them in the following article by Aurélien Clere.
Once we have the application created, and since this application is going to be executed from the F&O context, we will probably be interested in being able to visualize the information filtered by the context in which we are. In our case, this context will be the company (DataArea) and the customer for whom we want to visualize the sales. We can get this context in a very simple way, since F&O sends 2 parameters to our Canvas App (until version 10.0.19 it was only one). These parameters are the legal entity (dataAreaId) and the second one we can choose based on the place where we insert our app. We will use the client code.
To receive and use these parameters in our application, we will put the following lines of code in the OnStart method of the application:
If(!IsBlank(Param("EntityId")), Set(FinOpsInput, Param("EntityId")), Set(FinOpsInput, ""));
If(!IsBlank(Param("cmp")), Set(FinOpsLegalEntity, Param("cmp")), Set(FinOpsLegalEntity, ""));
The EntityId will contain the customer account, and with the cmp parameter we will receive the company code. Once both values have been set in the FinOpsInput and FinOpsLegalEntity variables, we can use them to filter the data of our application.
Once our application is finished, we only have to publish it and share it with the users of our organization who are going to use it.
Embed application in F&O
Now we have everything ready, it only remains to embed the application where we want. To do this, we can follow two different paths. The way of personalization, or the way of customization or development. So, which is the right way? Well, the answer to this is that it depends. It depends on the capabilities and needs of your organization.
The biggest advantage of the customization path, obviously, is the independence that the system gives you to make simple modifications without the need for a developer. On the other hand, the management and maintenance required to make these customizations available to the rest of the users is greater, and at any time (although it should never happen) a user with sufficient permissions could delete this customization “by mistake”, losing the work done.
On the customization side, these modifications would remain in the binaries of the application itself, being effective for all users at the time of deployment, obviously, without the need to distribute the customization and not being able to be removed by users with sufficient privileges, on the other hand, you have to have a developer for it.
Now that we know the advantages and disadvantages of both processes, let’s see how to perform each of them.
Embedding Power App through Personalization
The next thing we are going to do is to navigate to the form where we want to embed our Power App, in our case we will insert it in the Customers form, as a new FastTab inside the customer information, so we go to Accounts receivable > Customers > All customers, and click on one of them to enter the detail.
Once in the client, go to Options > Personalize this page, and on the customization bar that appears, click on the 3 dots (…) and click on Add an application.
Next, select the area of the form in which you want to insert the application (I have clicked on the fast tabs), and click on the Power Apps button.
Now the system will ask for the following data:
- Name: The name you enter will appear as the title of the Fast Tab to be added
- App ID: The ID of the application to be embedded
- Input context for the app: Here we indicate the value we want to pass as parameters (“EntityId” parameter) to the Power App in addition to the dataAreaId (“cmp” parameter)
- Application size: Wide or Thin
To obtain the identifier of our application, we can go to make.powerapps.com and see the details of the application we have created.
Once we click on the Insert button, we can see our application embedded into our form, without the need to develop, and, as we can see, showing the data previously filtered by the customer we have selected.
Finally, we can save the view with the name we want, and distribute it among the users who need to use it.
Embed Power App through Customization (or development)
In this second way, we are going to embed the Power App inside the same form, by means of a small customization or development, so we will need Visual Studio to achieve it. The first thing we are going to do, is to create an extension of the form in which we are going to insert it. For our example, we are going to extend the CustTable form, adding a new FastTab, in which we will insert a control of type Power Apps Host.
And finally we fill in (at least) the following properties:
- App ID: The ID of the application we want to embed (and that we obtained from make.powerapps.com)
- Data Source: The data source of the form we will use to send the EntityId parameter
- Entity Id Field: The field that we will use to send the EntityId parameter
- Using these two properties, we achieve the same effect as when filling the input context by means of personalization.
Now, let’s compile and see the results.
The conclusions are quite obvious: thanks to the Power Platform, the possibilities of extending the ERP have multiplied infinitely. We can now afford to think outside the box, let our imagination run wild, and build, with some creativity, components that we could not count on until now within our forms.
As for the way to choose (customization or personalization), I have clear which is my favorite, what about you? But as I indicated above, I don’t think there is one better than the other, just one more in line with your needs and capabilities.