Clone your leaflet here.
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:
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.
There are two main parts to create your app:
1. Create app connectors
To create a Business Central connector go to the File menu in the PowerApps Studio and choose Connections:
The connector to the Azure BC Container instance looks like this:
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:
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.
The second screen, DetailScreen displays a bit more fields from Items web service.
If the inventory is low, the app user can decide to order more by clicking on “Order more” button:
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:
And, in Business Central, the new purchase invoice:
This is what was needed on the PowerApps side, but additionally, I needed to plug a few new things in Business Central.
First, create a new AL project, and point Visual Studio Code to the azure container:
Launch.json:
Web services:
Page 50100 “PurchaseItemList” is a new page based on a new Table 50100 PurchaseItem:
Table 50100 PurchaseItem:
Page 50100 PurchaseItemList:
The Purchase Invoice is generated during OnInsert trigger on the new table:
Creating an app with PowerApps assumes 3 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:
Recently Microsoft announced that dotnet can still be used with installations on premise of Dynamics 365 Business Central.
However, if our extension is to make it in the cloud the code leveraging dot net needs to be replaced with http api calls.
In this example I will show how a legacy C/AL code using dot net can be replaced with a call to an Azure function to achieve the original goal of validating a posting code.
I want the additional validation to be executed when the standard validation is finished and the additional validation to not contain dotnet calls.
2. The codeunit itself contains an event subscriber to Table18.Validate.PostCode.
(Use “teventsub” snippet to get the quick scaffolding of the event subscriber)
When the subscriber is triggered we are executing an Azure Function call: azfnvalidate-us-ca-zipcode. We’re retrieving a json object whose content is : {“PCValid” : true} or {“PCValid” : false}.
3. Write the Azure Function with Visual Studio Code
Pre-requisites:
A good guide to get you started with Azure Functions is here.
Once you have the default “Hello World” Azure Function created, replace your Run function with:
Publishing the function in Azure should generate a record in your chosen storage:
2. Removing the “W” in the previous test, triggers the Azure Function to return above json.
3. Let’s test now the validation in Business Central:
Therefore, to replace a set of dotnet calls we need a worker placed somewhere else other than in AL or C/AL and a caller of that worker services placed in the extension. In my example use a codeunit (caller) in the extension range with a subscriber event defined that calls an Azure function(worker).
What other methods are you employing to achieve similar results ?
If you liked this article bookmark my blog or follow me for more stuff about NAV and Business Central.
When you turn On PerTenantExtensionCop in Visual Studio Code and you forgot to create a Permissions.xml file, you get a compile error in your extension.
In Visual Studio Code – > User Settings add an entry for al.codeAnalyzers token like below:
Without this flag turned on your extension compiles.
If you do set PerTenantExtensionCop and if you’re missing Permissions.xml, you’re going to get a compile error:
By Adding in the project root a file Permissions.xml the error is solved:
More reading on code analyzers here.
Original post here.
So much to read, so little time … the speed at which Microsoft adds new Business Central and AL features is overwhelming 🙂
In this blog I’ll demonstrate how I was able to display weather temperature for 3 cities in Business Central role center headline.
First, there are 9 headline role center pages in Business Central, with ID from 1440..1448.
I will extend the headline role center for the page 1440 : “Headline RC Business Manager”, by adding three fields, one for each city and its temperature.
To record the three cities and their temperatures I am using here a list and a dictionary data structure.
This is followed by a querying of a weather web service and recording of the 3 cities and their temperatures in a dictionary:
Commented is the response from the web service.
I need data stored in the following tokens:
For more info on how to parse web service response take a look at Mr. Kauffman blog.
I use a free web service for weather openweathermap. You need to create an account and you will get a free APPID when you complete the registration. You can only query the web service once every 10 minutes for the same location.
Finally, to load cities and their temperatures in your headline use the code below:
The complete pageextension object is included here.
That’s it … thanks for reading!
Original post here.