Thursday, February 14, 2019

#PowerApps: Simple Object Proximity and Collision Detection

As of late, I have been very interested in all things "Motion" as it relates to developing PowerApps applications - see #PowerApps: Motion Patterns with Parametric Equations. Although, most of the apps you will see tend to be around solving business problems, you cannot really dismiss the capabilities of PowerApps as a gaming platform.

The Basics

In this article, I explore a simple object proximity and collision detection approach, based on some simple logic. The world of gaming uses more sophisticated algorithms based on the laws of physics and what's not, but keep in mind that PowerApps is designed to be a low code/no code environment, hence access to user driven programmatic methods is extremely limited.

The following is a representation of the actual canvas apps I created for this example. It consists of 4 directional arrows to provide motion to smiley, a simple character added from the icons gallery. In addition, we have a rectangular obstacle added as well using the icons gallery. Finally, a slider which controls the steps of the smiley character in any direction. 

Canvas app

There are also two hidden button controls, which we will use to do branch logic. I have found that having code in hidden buttons act as a way to encapsulate logic that you can execute as if it were a method, as you can use PowerApps' Select function to run the On Select code behind the button.

For ease of setting control properties, I have grouped both the directional arrows in one group called Arrows, and the hidden buttons in another group called BusinessLogic, as shown on the left pane of design surface.

Adding Code

Screen On Visible

For the On Visible event, we are simply initializing the position of our smiley character. Smiley will be placed at roughly the center of the screen. The (X,Y) coordinates are stored in two context variables called xPos and yPos, which are then assigned to the X and Y property of the Smiley character.

You can set the obstacle icon away from Smiley, anywhere you want to.

Note: you could add a couple controls to input the position and width and height of the obstacle, but for simplicity sake, I have chosen to do this manually.

Directional Arrows Group

The directional arrows will control Smiley's motion up, down, left, or right, according to the arrow pressed. The up arrow will simple reduce the position on the Y axis, the down arrow will increase it. Conversely, the left arrow will decrease Smiley's position on the X axis, and the right arrow will increase it. All these movements are done in incremental steps dictated by the slide control value, setting the pace of the movement, if you will.

Note that I have chosen to define a directional variable, SmileyDirection, which tracks whether the motion is decreasing (up, left) or increasing (down, right).

Up Arrow

Left Arrow

Down Arrow

Right Arrow

Business Logic Group

Each time Smiley's motion is affected by the directional arrows, we need to evaluate whether its next step in that direction will put it in proximity with the obstacle, hence leaving it in danger of colliding on the next move.

The first logic branch says:

If Smiley's next step in the current direction (top, bottom) is within the horizontal boundaries of the obstacle - dictated by the value pair Rc1.X and Rc1.X + Rc1.Width - it will only be in the clear if it's outside of the vertical boundaries (the obstacle's height). Otherwise, Smiley would be in imminent danger of colliding on the next move in the current direction of motion - and this is where it gets interesting!

We also need to factor Smiley's own height when the motion is in the direction of the obstacle from the top as the value pair (Smiley.X, Smiley.Y) only represents the upper left corner of Smiley's position. In complex gaming design, this is done from the center of gravity of the object, but remember, we are not that fancy here.


If Smiley is not within the horizontal boundaries of the obstacle, then we need to similarly evaluate if Smiley it's within the vertical boundaries of the obstacle, while traveling left or right - dictated by the value pair Rc1.Y and Rc1.Y + Rc1.Height. Then, it stands to reason, that Smiley will only be in the clear, if it's outside the horizontal boundaries in the direction of travel.

Again, we want to factor in Smiley's width to ensure that if we are traveling towards the object from the right, we detect its proximity more accurately.


The Warning Label

Each EvalLogic button updates the CollisionWarning context variable, which is then assigned to the Text property of the label (place within the directional arrows pane).

The Final Results

When all the pieces are in place, the following is the final results:

Until next post,

Mariano Gomez, MVP

Monday, February 11, 2019

#PowerApps: Motion Patterns with Parametric Equations

As of late, I have been experimenting with motion in Microsoft PowerApps. This has actually helped me to revisit different mathematical models describing the motion of objects throw a two-dimensional space. As a result, I have created this video explaining how to create the following motion patterns:

You can download the msapp file from the PowerApps Community Apps Gallery here.

Until next post,

Mariano Gomez, MVP

Sunday, November 4, 2018

Analyzing expense receipts with Azure Cognitive Services and Microsoft Flow

Recently, Business Applications MVP Steve Endow and I delivered a session at the User Group Summits in Phoenix, and in particular, to the GPUG Summit titled, "Microsoft Dynamics GP and Azure Services". In this course we detailed a number of Azure Services (among the hundreds) that could potentially be used with Microsoft Dynamics GP.

Being that I have also been working my way through completing a Microsoft sanctioned PowerApps, Flow, and CDS self-paced, online training class offered by edX (click here for more info on the course) and presented by Business Applications MVP Shane Young, I asked myself, what could I do with Microsoft Flow and Azure Services that could benefit Microsoft Dynamics GP users?

Playing with some Azure Services, I came across Azure Cognitive Services which offers the capability of reading images and analyzing them for text via its Computer Vision service. As it turns out, this service offers an optical character recognition (OCR) feature, which is capable of returning the full text or a JSON formatted document with the text. The idea here would be to use Microsoft Flow to read a newly created receipt in a OneDrive folder and transfer the file to Cognitive Services' Computer Vision for analysis, then get back the parsed text from the OCR service. 

Let's see how it's done!

Provision the Computer Vision service

The first thing is to ensure Computer Vision has been enabled as a service on your Azure tenant. For this visit the Azure Portal, click on Create a Resource, then select Computer Vision from the AI + Machine Learning category within the Azure Marketplace. 

Computer Vision

Fill in some basic information like the resource name, location, pricing tier (there's a F0 free service!), and a resource group. Click the Create button when done. This will provision your Computer Vision resource.
Copy the service endpoint address and access keys

Once the service is provisioned, click on All Resources, select the Computer Vision resource you just created, then click on Overview.

Grab the service endpoint address and the access keys. You can obtain the access keys by clicking on Show access keys.. (two access keys are provided). 

Computer Vision service endpoint info

This is, by far, one of the easiest services to provision and requires no extra configuration, beyond establishing some access control to limit who can use the service, but that's not a topic for this discussion.

Setup a new Microsoft Flow flow

Over in Microsoft Flow, I started by setting up a blank flow and selected OneDrive's "When a file is created trigger" as this would setup the simple trigger point for when an expense receipt file is added to a Receipts folder I had previously created. You will then be prompted to setup the connection information for OneDrive.

Blank flow with "When a file is created" trigger

NOTE: I selected my personal OneDrive for this, but this can also be done with a folder on your OneDrive for Business environment. In this case, you will want to authenticate with your Office 365 credentials.
Receipts folder

Submit file to Computer Vision service

As it also turns out, Microsoft Flow has a connector to the Azure Computer Vision API, which exposes two actions: OCR to JSON and OCR to Text. Add a New Step and type Computer Vision in the search bar. Select Computer Vision API, then choose OCR to Text action.

Computer Vision API connector - OCR to Text action

Once again, you will be prompted for the connection information to your Computer Vision service on Azure. Enter the user account, the access key and service endpoint as gathered in step two, above.

Computer Vision API - credentials entry
Once credentials are entered, you can decide what to submit to Computer Vision. In this case, we what to send the File Content, which we can select from Dynamic content fields.

File Content from Dynamics content fields

Configure Email step with Results

Upon completion, we want to send the resulting OCR from the analyzed image via email, so we will add another step to the flow. This time, we will a connector to Office 365 Outlook and will choose the Send an Email action for our next step.
Office 365 Outlook connector - Send Email action

We can then setup the properties for the Send an Email step. I have chosen to send the email to myself, and compose a subject line using the File name from the OneDrive directory. As body, I am including the Detected Text, which can be selected from the OCR to Text category under Dynamic content. I've included both the original file and content as part of the attachments.

Finally, I have given this flow a name and saved it.

Testing the Flow

I have dropped two receipt files within my OneDrive Receipts folder. These two receipts present various degrees of quality and text that can be recognized by the service. I was particularly interested in the second receipt (right) as this one was very folded and cracked so I was curious to see how it would be analyzed.

For the second receipt, the OCR service returned the JSON payload and a status 200, indicating it was successful in processing and delivering a response.

JSON payload for second receipt

The actual email I received look like this and contained the following text:

Receipt analysis

Now, remember that my goal isn't to judge the accuracy of the OCR result delivered by Computer Vision, but rather to show how easy it is to build these kinds of solutions with Microsoft Flow and existing Azure services. Something like this would take an inordinate amount of time to build using traditional development tools and services.

Conceivably, I could create a simple PowerApps application that uses the Camera control to take the picture of the receipt and save it to my OneDrive folder. At this point, the receipt would be picked up by the Flow and analyzed by Computer Vision as we have established here. Why would this be important? Perhaps if you want to parse the JSON payload and rather submit to Microsoft Dynamics GP or Dynamics 365 as an account payables voucher, this would be useful.

Until next post,

Mariano Gomez, MVP

Friday, October 19, 2018

Installing Microsoft Azure Integration Runtime

The Integration Runtime (IR) is a customer managed data integration infrastructure used by Azure Data Factory to provide data integration capabilities across different network environments. It was formerly called as Data Management Gateway.

It is used by Business Central and Dynamics GP to provide a one-way data synchronization between your on-premises SQL Server hosting your company databases, and your Business Central tenant data store in the cloud via Azure Data Factory.

The self-hosted IR is capable of:
  • Running copy activity between a cloud data stores and a data store in private network.
  • Dispatching the following transform activities against compute resources in On-Premise or Azure Virtual Network: HDInsight Hive activity (BYOC), HDInsight Pig activity (BYOC), HDInsight MapReduce activity (BYOC), HDInsight Spark activity (BYOC), HDInsight Streaming activity (BYOC), Machine Learning Batch Execution activity, Machine Learning Update Resource activities, Stored Procedure activity, Data Lake Analytics U-SQL activity, .Net custom activity, Lookup activity, and Get Metadata activity.
To install, go to the Assisted Setup page and download the installation file. Copy the authentication key as you will need it for the configuration step.

NOTE: Be sure to scroll horizontally to the end of the line while selecting the key text.

Launch the installation file to begin the setup process. You must first select the language which you will be using with the Integration Runtime.

Accept (or not) the end-user license agreement to continue with the installation process.

Select the installation folder to host the application files.

Click the install button to begin the installation process. You may be prompted to run the application with elevated permissions to bypass User Account Control settings on your machine.

Once the installation has been completed, click Finish to proceed with IR's configuration.

Paste the Authentication Key from step 1. If you require to bypass proxy settings within your organization, be sure to click on the Change link to setup your proxy info.

The following screen will allow you to enter the name of the self-hosted node and will display a list of nodes as configured by Business Central on the Azure Data Factory service. Also, you may enable remote access from your intranet to the integration node. Click finish when done.

If you choose to enable remote access for management purposes, you must enter an open TCP/IP port on your firewall. By default, this port is 8060. Should you want to enable secure access to while remoting into the node, be sure to select a certificate. You can also enable remote access without a certificate.

Finally, click on Finish to complete the configuration settings an finalize the node registration process.

For more information on Azure Data Factory, please visit:

For more information on Azure Integration Runtime, please visit:

Until next post,

Mariano Gomez, MVP

Monday, October 8, 2018

Provisioning a Microsoft Dynamics 365 Business Central demo tenant

With the release of Microsoft Dynamics GP 2018 R2, I had a first look at the update process, then quickly ran into a situation where the option to set up intelligent cloud insights wasn't showing in my already provisioned Microsoft Dynamics 365 Business Central tenant - See, "Set up Intelligent Cloud" option not showing for Microsoft Dynamics 365 Business Central tenants.

I also noted that this option was available with the October '18 Release and that the current tenants would be undergoing upgrades within the next 30 days. In the meantime, if you want to familiarize yourself with the process of deploying intelligent insights, you will need to provision a demo tenant, built on the October '18 release.

Here's how you do this:

1. Launch your browser and enter in the address bar. This will take you to the Microsoft demo site. The site can be accessed either with your Microsoft account or your Work account (organizational or Azure AD authentication).

Microsoft Demos (
NOTE: If using your work account, you must be a Microsoft partner or MVP to access the site.

2. Once on the Demos site main page, click on My Environments on the upper menu bar.
Main Demos page
3. Once on the Environments page, click on Create a Tenant.

Environments page

4. On the Tenant page, locate the Microsoft 365 Enterprise with Users and No Content section, then click on Create Tenant.

Tenant page

: you can provision a tenant for a period of 90 days, which should give you plenty enough time to get started.

5. Once the environment has been provisioned, please take note of the admin user and password you have been assigned as this will be needed to complete the additional steps.

6. Launch your browser and open an In Private session (Edge) or Incognito session (Chrome). In the URL bar, type
Enter the admin credentials assigned to you in the previous step. The environment will then be prepared for you:

7. Once the environment has been prepared, proceed to click on Get more apps.

Get more apps

8. Type "Business Centr.." in the search bar to narrow down the list of apps to Business Central, then select Microsoft Dynamics 365 Business Central (Trial), to initiate the free 30-day trial.

Business Central app
9. Now, all you need to do is agree to the terms of use and privacy terms and you are now on your way to provision and Business Central tenant.

Terms of Use and Privacy Terms agreement
You will have 30 days to work with this tenant before it expires. I assume if you need more time, you can delete the demo environment and start all over again. However, I find it more beneficial to simply have your own Business Central tenant as existing tenants should see the October '18 release applied to them anytime now.

Hope you find this useful.

Until next post,

Mariano Gomez, MVP

Wednesday, October 3, 2018

"Set up Intelligent Cloud" option not showing for Microsoft Dynamics 365 Business Central tenants

I was (still am!) seriously excited about the release of Microsoft Dynamics GP 2018 R2 - I mean, how can you not? This Intelligent Cloud thing is just superb! The simple premise of being able to sync your data to Microsoft Dynamics 365 Business Central and use the power of the cloud to get actionable insights is just too good to pass up on.

See my article, Microsoft Dynamics 365 Business Central: the perfect complement for Microsoft Dynamics GP users.

In fact, I already had an Office 365 Business Premium tenant provisioned with an instance of Dynamics 365 Business Central for IW. This is my playground, where I learn about the new stuff, where I try to build up my AL development skills, etc., (albeit at a turtle's pace 😊).

After updating my GP 2018 RTM instance to GP 2018 R2, I proceeded to setup the Intelligent Cloud Insights which, in a nutshell, involves setting up an integration between my on-premises Microsoft Dynamics GP application databases and Microsoft Dynamics 365 Business Central using an Azure Data Factory - a hybrid data integration (ETL) cloud service - and an integration runtime that allows to control what companies within a Business Central tenant get synced to what companies in Microsoft Dynamics GP and when.

The steps are fairly clear in this Microsoft Docs article, Connect to the intelligent cloud with Dynamics 365 Business Central. But in particular, when I went to the Assisted Setup page to locate the Set up Intelligent Cloud option, I could not find that particular entry.

Business Central Assisted Setup guide

Upon exchanging a few emails with the Microsoft Dynamics GP Product Management team, it was noted that this feature - Set up Intelligent Cloud - is part of the Dynamics 365 October '18 release and is not in the currently deployed Business Central tenants. The October '18 release should be out any time now and once that update is applied, you should gain the ability to enable intelligent insights for your Microsoft Dynamics GP 2018 R2 on-premises instances.

In the meantime, you can head over to Microsoft Demos to provision a Business Central demo environment with the October '18 release features that you can use to test and familiarize yourself with intelligent insights.

Until next post,

Mariano Gomez, MVP

Updating to Microsoft Dynamics GP 2018 R2 - First look

Yesterday marked the release of Microsoft Dynamics GP 2018 R2 to the English speaking market - other languages soon to follow. After a few hiccups in the download process (make sure you clear your browser cache before attempting to download), I was able to get my hands on the 1.81 GB zip file containing the actual installation media (1.92 GB unzipped).

Since this is not a major release, I went straight for the Updates folder on the image and executed the MicrosoftDynamicsGP18-KB4458410-ENU.msp file - The msp file was also published separately on the Service Pack, Hotfix, and Compliance Update Patch Releases for Microsoft Dynamics GP 2018 page on PartnerSource and CustomerSource and it probably offers a better download experience and less of a footprint, if all you need is to update an existing Microsoft Dynamics GP 2018 instance.

Applying the msp is a fairly straight forward process. However, if you need instructions for a full install, take a look at my article Microsoft Dynamics GP 2018 installation - First Look which shows the full installation process. Apparently, there were some updates to the Dexterity Shared Components, so you will see the bootstrap setup in action, working to update those.

The system database update went extremely fast on both my server and client environments and I couldn't be happier with this initial experience. Next up was the Fabrikam database.

NOTE: For this update, I have 2 environments: a Windows Server 2016 running SQL Server 2014 on a Dell PowerEdge 1950 with 32GB of RAM and Dual Xeon 2.24 GHz and a Windows 10 running SQL Server 2014 running on a Dell XPS L701X with 16GB of RAM and SSD drives, both with Fabrikam and all Mekorma products and test data, totaling close to 550 MB each. And while for many, Fabrikam is not a good indicator of how upgrades will turn out, I've learnt over the years that is a very good predictor.

The Fabrikam update completed in or around 15 minutes on both my server and my laptop machine. I didn't find this to be out of the norm considering I was dealing with a 550MB database, in both cases.

Upon launching Dynamics GP, things will seem very normal, until you take a closer look at the homepage, where you will notice a link, the homepage header for Intelligent Cloud Insight.

Dynamics GP Homepage
Clicking on this link will bring up the new Business Central Intelligent Cloud for On-Premises Customers page, which can be accessed directly via your browser here. Where you can begin setting up Intelligent Cloud by clicking on the TRY IT OUT button.

Intelligent Cloud Insights page

My fellow Microsoft Business Applications MVP, Jen Kuntz has a full comprehensive write up on how to configure Intelligent Cloud here, so I will not double-down on this.

NOTE: I don't know if this will become a recurring problem, but I ran into some page scripting issues, but clicking Yes to continue running the scripts on the page simply seems to work all the time, although annoying. My friend, Jen Kuntz, seems to have ran into this as well.

Intelligent Cloud Insights page scripting error
It's worth noting that you can control whether the standard homepage gets displayed vs the Intelligent Insights page when you switch between options on the Navigation Bar, via the homepage customization link, Customize this page...

Customize Home Page window
One thing to note...

After launching Dynamics GP and login into the system, messages did not get re-added to the Alert Messages table (SY01700). This was actually a time saver and improved the overall experience -- oh, the small things in life 😊.

Until next post,

Mariano Gomez, MVP