How to PowerApps with Business Central

Standard

PowerApps – Intro

What is PowerApps? PowerApps is a service for generating cross platform (iOS, Android, Windows Store) applications. It allows connectivity to different systems, comes up with cloud IDE and a cloud admin interface that allows users to publish apps targeting whatever platform you need. The IDE is called PowerApps Studio and can be downloaded from Windows Store locally on your machine or it can be used as a web application. I designed the app detailed below using the web application.

Most importantly, just like the other power tools, PowerBI and MS Flow, PowerApps is accessible not only to professional developers, but also business analysts, junior developers, or expert users in any company. I wrote this app without any code inside PowerApps Studio, just a few Excel functions invoked sporadically.

The quick PowerApps app I built required:

  • a PowerApps license. I got my free license here.
  • a NAV container hosted on Azure. You could build yours easily, some help here.

Application scope

The app will get from the Azure Business Central container the list of items via Item List page exposed as web service, and will present on the first screen the Item No. and Description for all items. App user can then advance into the details screen for each item. Here, if the Quantity is low the user can advance on a third screen where he can generate a purchase invoice for the desired quantity for the item and vendor selected. The result is that in Business Central the app will generate via a second web service a purchase invoice for the item, the vendor selected and the quantity entered.

Application design

There are two main parts to create your app:

  1. Create app connector
  2. Design app

1. Create app connectors

To create a Business Central connector go to the File menu in the PowerApps Studio and choose Connections:conn

 

The connector to the Azure BC Container instance looks like this:

 

new bc connector

Once the connector is set we can access all web services exposed in Business Central Azure Container.

2. Design PowerApps app

The PowerApps Studio comes with 3 main regions:

  1. Left Side is where you work with the screens. In this simple app I have 4 screens: Master, Detail, Order and Confirm.
  2. The center belongs to the canvas where you drop your controls
  3. Right side is occupied by the Data Source (if any) and the properties of the current control you selected on the canvas

 

studio screens

MasterScreen consists of a Galleria control (GalleriaItems) which contains a list of items retrieved via Items web service Data Source. You will see later that this web service is Page 31 exposed as web service in Business Central Azure Container.

OnSelect event for the Forward button has Navigate(screen,effect) function behind to advance to a certain screen in your app.

forwardbutton

The second screen, DetailScreen displays a bit more fields from Items web service.

detailscreen

If the inventory is low, the app user can decide to order more by clicking on “Order more” button:

orderscreen

Once the user enters the desired quantity to be included on a Business Central Purchase Invoice the app will create a POST request to a new ODATA web service data source (OrderItemVendorWS) and ultimately generate the purchase invoice with one purchase line.

Let’s see the app:

runappgiflast

 

And, in Business Central, the new purchase invoice:

purchaseinvoiceinbc

This is what was needed on the PowerApps side, but additionally, I needed to plug a few new things in Business Central.

Business Central Container changes

First, create a new AL project, and point Visual Studio Code to the azure container:

Launch.json:

launchjson

Web services:

  • Items service will support MasterScreen and DetailScreen
  • OrderItemVendorWS will support OrderScreen.

web servicesPage 50100 “PurchaseItemList” is a new page based on a new Table 50100 PurchaseItem:

Table 50100 PurchaseItem:

TabPurchaseItem

Page 50100 PurchaseItemList:

Pag50100PurchaseItemList

The Purchase Invoice is generated during OnInsert trigger on the new table:

InsertTrigger50100

Conclusions

Creating an app with PowerApps assumes 3 tasks:

  1. the app backend, the connectors to your apps
  2. the app design, done in PowerApps Studio
  3. Publishing and Management tasks

PowerApps comes with versioning and management capabilities of a few environments (E.g. Dev, QA, Prod). Once your app has been tested by PowerApps app users, you could export it from QA and import it in Prod and distributed it from there. Select Office and  Dynamics 365 plans will allow you to generate and manage these environments.

More specifically, if you go to web.powerapps.com and click on Solutions you will be able to follow (with the right license) Create a new environment link.

Some useful links:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s