With PowerApps and Flow we have a very strong toolbox that allows us to augment standard Dynamics 365 for Finance and Operations (D365FO) features and provide “last-mile” solutions. In this two-part series I explore how we can use PowerApps to augment standard functionality and Flow to provide sophisticated data processing capabilities.
In the following example I am trying to support the following scenario:
The company is keeping track of what equipment is on loan to employees through the Loaned equipment function in the Human resources module. An employee can open a PowerApp and scan the bar code on the equipment to start a new loan. This will close the existing loan record and create a new loan record. In addition, the HR-administrator is informed about the loan through an e-mail.
The following screenshot shows the screen in my PowerApp where the user can scan the bar code.
To support the above scenario I need data to flow from the PowerApp via Flow to D365FO. The data flow is described in the following steps:
In this part of the series I will look at points one and two. In the next part we will be looking at points three and four.
The first thing we need to do is to invoke a Flow from the PowerApp to get the process going. However, before I go into PowerApps to configure this, I need to set up the Flow to make it available to PowerApps. To make a Flow available in PowerApps, the first step in the Flow needs to be a PowerApps-trigger as shown in the below example.
Next step is to determine what data (parameters) I need pass from PowerApps to drive my Flow. As the following screenshot shows, I need Barcode, Purpose, UserId, FromDate and ToDate as data from the PowerApp.
This data is used to create the SharePoint item. When linking a parameter in PowerApp to a field in the Sharepoint list, I need to use the Dynamics content provider called “Ask in PowerApps”. This connects the PowerApp-parameter with the SharePoint list field when the Flow is called.
To invoke a flow from PowerApps you need to use the OnSelect method on a control (in my case the control is called “Icon5”. On the Action pane in the ribbon, use the Flows button to link the control to a flow.
As shown in the following screenshot, this brings up a dialogue that allows me to select between the flows available in my organisation.
In this case, I have selected the flow called “PowerApp->Createitem”. This immediately posts the following code into the OnSelect method on the Icon5 control:
PowerApps is now linked to the Flow and I must fill in the parameters, I have requested in the Flow. This results in the following OnSelect method code:
When clicking on the Icon5 control in the PowerApp, the Flow will now be invoked with the data defined in the parameter-string.
As mentioned above, all I need to do now is to update existing open equipment loan records in D365FO. This is due to a business rule on the LoanedEquipments data entity that does not allow new loans if a loan exists without a returned date.
To do this, I use the Flow connector called “Dynamics 365 for Finance and Operations”. This connector has an action called “Get records” and as the following screenshot shows, I use this action to select all open equipment loans.
Two things worth nothing in the Filter Query I am using to find the correct records:
Please note: Depending on your locale, the statement separator can be either “,” or “;” and the system may expect single or double quotes.
For each record found by the query, I use an Apply to each construct to update the returned date (sorry for the Danish) in the LoanedEquipments data entity.
As the above example shows, it is relatively simple to create functionality that combines a user interface (PowerApps) with data processing (Flow) using the Power Platform in combination with D365FO. In my example I also create an item in a SharePoint list. This is mainly to demonstrate this capability and could have been omitted.
In the next part in this series, I will show how to create a record in D365FO based on the data stored in the SharePoint list. Stay tuned…