15) Calling PowerApps from D365 for Finance and Operations

Introduction

After watching D365 spring release’18 virtual launch events sessions, I was greatly impressed by PowerApps and D365 for FO integration session. This feature enables power users to create their own apps and seamlessly integrate them with D365 for FO even without any help from developers.
I decided to look deeper into this new feature and in order to learn more about it, I’ve decided to do it by building my own integration case.

Integration case

I decided to build the following integration case, that is very close to real life scenarios: imagine you are entering a customer data, you enter customer’s unique tax payer ID (INN in Russia) and would like to get information about the customer from a public web service.
Throughout my blog post I describe how I’ve build PowerApps application that fetches organization information (company name, address, director name, etc.) by tax payer ID and how I’ve integrated this PowerApps application with D365 for FO.

Choosing web service

First, I had to choose web service that will provide company data by tax payer ID (INN in Russia). There is a number of such web services in Russia, most of them offer free access with limited number of requests per day.
I chose web service from DaData. This service offers a lot of functions, including function for fetching company data by tax payer ID. This service works only for companies in Russia and all documentation is also only in Russian.
DaData Web Service

Building custom web service connector in PowerApps

After we’ve chosen web service, it is time to start building custom connector for this service in PowerApps. Connector is needed to load data from web service into PowerApps application. Connector is a wrapper around an API that allows the underlying service to talk to PowerApps.
You can find detailed instructions on how you can create your own custom connector at #Build2018 session: Developing custom connectors for Microsoft Flow and PowerApps.
I will briefly describe how I created  custom connector for DaData web service in PowerApps step-by-step.
First, download Postman application. This application helps to create connectors to web services end points. Since PowerApps supports Postman, it significantly reduces time needed to create custom web service connectors in PowerApps. Your can import connector definition from Postman, rather than creating from scratch.
http://www.getpostman.com – Downloading the Postman application
In Postman application we enter end point URL for our web service (DaData in our case), click “Send” and check if you get correct results in response. For DaData web service authorization is done via token string and I’ve entered token value at “Headers” tab page.
Send sample request to web service in Postman
If sending request was successful you can save the request to your collection. I’ve created “DaData” collection.
Save request to your collection in Postman
Now you can export your collection from Postman, to do this expand collection and click “Export”, choose version 1 format. After that you’ll have “DaData.postman_collection.json” file at your local disk.
Export Postman collection – Step 1
Export Postman collection – Step 2

Building PowerApps application

Now we can open our web PowerApps home and import request definition from file that we’ve downloaded from Postman. So we go to “Customer connectors” and select “Import a Postman collection”.
Import a Postman collection to PowerApps custom connectors – Step 1
Import a Postman collection to PowerApps custom connectors – Step 2
You can see that there is “Find by tax ID INN” action at the connector definition tab page, this is action that I’ve defined later in Postman when I saved it into collection (Request name). After your setup all necessary properties for the connector, you can save it and it appears on the custom connectors list.
Custom connector for DaData web service in PowerApps
Now you can develop PowerApps application based on this connector. I’ve developed a simple PowerApps application named “OrganizationInfo”. This application requests tax payer ID and then connects to the web service via the custom connector and list all relevant companies that match this ID. You can click company in the list and get more detailed information: company address, name of general director and some other company details.
PowerApps application OrganizationInfo
Below in the picture you can see how does my PowerApps application look in the designer. Building applications in PowerApps is very easy and does not require developer skills. Development in PowerApps can be done by power users, that’s why integration between D365 for FO and PowerApps that appeared in spring release’18 is really helpful. Power users can develop PowerApps applications and easily integrate them with D365 for FO without involving experienced D365 for FO developer.
PowerApps application designer

Integrating PowerApps and D365 for FO

Now, when PowerApps application is ready, I’ll show you how you can easily and seamlessly integrate it with D365 for FO. You’ll need D365 for FO spring release’18 or later version (platform update 15 or higher), since this integration feature appeared in spring release’18.
According my scenario I would like to open PowerApps application from D365 for FO customer details page and would like automatically pass tax payer ID from D365 for FO to PowerApps application. To do this, first, open customer details page in D365 for FO, we’ll assume, that tax payer ID is stored in “Government identification – ID number” field. Imagine, that I’m filling in details for new customer and just filled in tax payer ID number, and now I want to fetch all company details using this ID.
D365 for FO customer details page – Tax payer ID field for our scenario
Please, note that starting from D365 for FO spring release’18, there is special PowerApps button in every form. Using this button you can add PowerApps application to any form in D365 for FO.
PowerApps button in D365 for FO forms
Let’s add our “Organization Info” PowerApps application and setup it so that application will automatically get tax payer ID from D365 for FO customer details page. To do this, click “Insert a PowerApp” menu item, you’ll see “Insert a PowerApp” dialog window. You will new PowerApp App ID, this ID looks like GUID and can be found at PowerApp application details page at web PowerApps home.
In “Input data for the PowerApp” select control with “ID number”, value from this control will be automatically passed to the PowerApp. For our app we’ll select thin application size. Now you can click “Insert” button and app will be added to the list of available PowerApps applications for the D365 for FO form (customer details in our case).
Insert a PowerApp dialog
“Organization info” is on the list of available apps
In order to use value from D365 for FO field in PowerApps application, we shall modify our app. Go to PowerApps application designer and setup default value for tax payer ID field in PowerApps application designer. Use global variable “FinOpsInput”, this variable contains input value from D365 for FO form.
Use “FinOpsInput” global variable to supply a default value to PowerApps
Now let’s try to call our PowerApps application from D365 for FO customer details form. Note, that value from “ID number” field has been automatically transferred to PowerApp. In PowerApps application you just click “Find” button and get all company data from DaData web service.
Calling PowerApps application from D365 for FO

Conclusion

Hope, this real life scenario would be helpful for your D365 for FO implementations. Main advantage of using PowerApps in D365 for FO is that you do not need experienced developer to do any extensions in D365 for FO. If you are just power user you can easily create your own PowerApps application and integrate it with D365 for FO just in few clicks.

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++