Overview of Dynamics 365 Business Central October ’18 release

Original URL…

Improved Visual Studio Code AL experience

Be more productive when developing and troubleshooting extensions with new and improved developer tools, such as sandbox environments with production data, improved breakpoint support, better inline Help, ability to trace raised events in a given user scenario, support for .NET Interop for on-premises deployments, extension support for enums, report data set and field groups, and more.

Anuncios

NAVBaaS Git – Extention

Original URL…

NAVBaaS Git

NAVBaaS Git for Dynamics NAV & Dynamics 365 Business Central

NAVBaaS-Git for Microsoft Dynamics NAV

This extension provides the integration between your dockerized C/SIDE development environment and git.
The commands will take care of keeping your C/SIDE development environment in sync with your git repository so that you can focus on what’s really important: developing!

If you’re having trouble with the NAVBaaS.Git extension, please follow these instructions to file an issue on our GitHub repository:

Make sure to fill in as much information as possible and try to provide a reproduction scenario.

  • Git for Windows Download Link.
  • Windows or Windows Server with Docker for Windows installed Follow Instructions.
  • Your Dynamics NAV solution must at least be based on NAV 2016 or beyond.
  • PowerShell Module: Navcontainerhelper (will be installed and managed by the extension)
  • PowerShell Module: SqlServer (will be installed and managed by the extension)

This extension will add a number of settings to your Visual Studio Code User Settings, all prefixed with NAVBaaS.
When following the normal flows as described below there’s no need to adjust these settings manually.

  1. Install the extension and press reload so that the extension can be used.
  2. Run Visual Studio Code with Administrator privileges.
  3. Execute command: NAVBaaS: Go! command and follow the steps.
  4. Move your splitted objects (text files) to the modified folder. It is required to use the default file naming conventions, for example: TAB1, COD1, PAG1.
  5. Stage and commit your files.
  6. Execute command: NAVBaaS: Create Container command to create your dockerized C/SIDE development environment.
  7. Execute command: NAVBaaS: Sync. command to initially import all the objects from your git repository.

If you already have your solution in git, please be aware that by default, the extension expects the following two folders in the root:

  • modified
  • original

You can change this by adjusting the following user settings:

  • NAVBaaS.ModifiedFolder
  • NAVBaaS.OriginalFolder

Below you can find a list of all the commands together with a brief explanation.

NAVBaaS: Go!
Command used to initially setup the extension on your machine, it will perform the following actions:

  • Select your git repository.
  • Initialize the folder structure in your git repository.
  • Select your Dynamics NAV development license.
  • Install the required PowerShell modules.

NAVBaaS: Open Git Repository Folder
Opens your configured git repository folder.

NAVBaaS: Create Container
Command used to create your C/SIDE development environment in a Docker container. You will be prompted to enter the following information:

  • Container Name.
  • Docker Image Name on which your solution is based. For example Microsoft/dynamics-nav:2018-cu5-nl
  • Authentication Type: can be either NavUserPassword (recommended) or Windows.
  • Which database to use: Cronus or your own .bak file.

*Only when a container is successfully created it will be stored in your user settings under: NAVBaaS.Containers.
*Only containers created through this command can be used with the Sync. command.

NAVBaaS: Remove Container
Command to remove your container when you’re done with it.
Please always remove your containers through this command so that related settings, folders etc. can also be cleaned up.

NAVBaaS: Sync.
Command used to keep your git repository and Dynamics NAV development container in sync.
The command handles the following tasks in one go:

  • Determine if there are any conflicts. If that’s the case the synchronization will stop – conflicts should be handled manually by using a compare tool.
  • Import changed objects from your git repository to your NAV dev. container.
  • Export and commit changed objects (based on modified flag) from your NAV dev. container to your git repository.
  • Remove objects which are deleted from your git repository from your NAV dev. container.
  • Compile uncompiled objects.
  • Synchronize schema changes.

Please note that when modified objects are exported from your NAV dev. container, a fixed DateTime property will be set on the object.
This is done to prevent conflicts when multiple developers are working on the same file(s).

NAVBaaS: Sync. Preview
Command used to preview the synchronization of the container without performing the import, export or delete.

NAVBaaS: Sync. Schema Changes
Command used to perform the schema synchronization inside the container. This can be handy when you make changes to the schema through C/SIDE and saving the table with validation does not work.

NAVBaaS: Compile Objects
Can be used to compile objects inside the container.
This can be handy when you cannot compile an object through C/SIDE because of server side dll dependencies.

NAVBaaS: Compare
Can be used to make object comparisons, the following scenario’s are supported:

  • Compare an object from the original folder with an object from the modified folder.
  • Compare an object from the modified folder with an object from your database (inside the container).

If you need functionality before or after creating the container you can use the two following settings in your user settings. OnBeforeCreateContainerScriptPath – will be executed before the container is created, the following variables can be used:

  • $AdditionalParameters – will be passed to the New-NavContainer command (navcontainerhelper module).
  • $IncludeTestToolkit – true by default.
  • $DoNotExportObjectsToText – true by default.
  • $EnableSymbolLoading – true by default.

OnAfterCreateContainerScriptPath – will be executed after the container is created, the following variables can be used:

  • $ContainerName – name of the created container.
  • $DockerImageName – name of the used docker image.

A way to deal with Extension IDs in NAV (Business Central) AL

Original URL...

In AL VS Code Extensions V2, if you try to create an extension and the ID or Name are already used, you get this error:

Because we don’t have the extension id in the name of the file (I assume you don’t have it either), you can use the following Powershell script to check what files are using the same name for example (change according to your need):

1
2
3
4
$Folder = 'your folder\with extensions'
$SearchString = 'pageextension50545' #your search string
$File = (Get-ChildItem $Folder -Filter '*.al' |
Where-Object {Select-String $SearchString $_}).Name
$File

This code will search for the string in the first line of each file and show you what files contain the same Id/name:

! Ok, this was the easy part. Now I want to assign a different Id (the next free Id) for my current file, in order to fix the error. But which is the next ID ? In good old C/SIDE it was so easy to find out things like this…

In order to find out the next free Id in AL, I need to look in each file and compare all the Ids to see which one is the greatest. The problem is that by now I have 200-300 files, so it will probably take around one week to do this manually…

Not when we have Powershell 🙂

First let’s see the situation from my example (you can then adapt the script for your own situation):

–> I have 1 folder with 2 sub folders with AL Page Extension files:
* Files in folder 1 are named like this:

* Files in folder 2 are named like this:

* The first line of each file contains information about the page extension like this:
pageextension 50333 pageextension50333 extends “Bank Account Card”

So, let’s look automatically in each file at the first line, create an array with the IDs, Object Name that it extends and other useful information about the files:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Function Get-ALExtensionFilesInfo{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)][array]$ALExtensionFiles,
        [switch]$GetIDFromExtensionName,
        [switch]$GetObjectNameFromFileName
        )
    If($GetIDFromExtensionName) {
        #let's complicate things for practice with
regex and extract the ID from the extension
name instead of simply take the Id
        [regex]$Regex = '[a-zA-Z]+(?<num>\d+)'
    } else {
        [regex]$Regex = '(?<num>\b\d+)'
    }
    $ExtensionNumbers = @()
    foreach($File in $ALExtensionFiles)
    {
        $ExtHash = @{}
        $stringfirstline = (Select-String
-InputObject $file -Pattern $RegEx | select-object -First 1).Line
        $m = $Regex.Matches($stringfirstline)
        $number = ($m[0].Groups["num"].Value) * 1
        $ExtHash.Add("FileName",$File.FullName)
        If(!$GetObjectNameFromFileName) {
            #match the object name from the first line
(after word 'extends'):
            $ExtHash.Add("ObjectName",(([regex]::Match
($stringfirstline,'(?<=extends ).*').Value) -replace '"','').TrimEnd())
        } else {
            #OR match the object name from file name: ex Name of file is 'PEX50343 - Test.al' or 'PEX - Test.al'; Object Name is 'Test.al'
            $ExtHash.Add("ObjectName",[regex]::Match($File.Name,'(?<=PEX(?:\d+)? - ).*').Value)
        }
        
        $ExtHash.Add("ExtensionNumber",$number)
        $ExtHash.Add("ExtensionType",[regex]::Match($stringfirstline,'^\b\w+'))
        $PsObject = New-Object PSObject -property $ExtHash
        $ExtensionNumbers += $PsObject
    }
    return $ExtensionNumbers
}

Let’s see how to use this function:

1
2
3
4
5
6
7
8
$Folder = 'C:\ALExtensionIdsSample\Folder 1'
$Folder2 = 'C:\ALExtensionIdsSample\Folder 2'
$Files = Get-ChildItem $Folder -Filter '*.al'
$Files += Get-ChildItem $Folder2 -Filter '*.al'
#get the info from extension files
$ExtensionInfo = Get-ALExtensionFilesInfo -ALExtensionFiles $Files
$ExtensionInfo

–> And now we have an array with custom objects that we can use:

For example, to get the last used extension ID for page extensions:

1
2
3
4
5
6
#get the maximum used id for page extensions
$MaxMinNo = $ExtensionInfo |
            Where-Object{$_.ExtensionType -like 'pageextension'} |
            Measure-Object -Property ExtensionNumber -Maximum -Minimum
$ExtensionInfo | Where-Object {($_.ExtensionNumber -eq $MaxMinNo.Maximum) -and
                               ($_.ExtensionType -like 'pageextension')}

Output:

Or I know I have a page Extension for page “Tranfer Order” and I want to retrieve the Id:

1
2
$ExtensionInfo | Where-Object{($_.ObjectName -like 'Transfer Order') -and
                              ($_.ExtensionType -like 'pageextension')}

Output:

–> Or the opposite example when I have the Extension Id and I need to find out the Name of the Object that it extends:

1
2
3
$ExtensionInfo | Where-Object{($_.ExtensionNumber -eq 50292) -and
                              ($_.ExtensionType -like 'pageextension')} |
                 Select-Object -Property ObjectName

Output:

For this script I used some simple powershell commands and a little bit of Regex. This is not a final product, but more a script made quickly when I was in need 🙂

What do you say, would it be helpful a Powerhell module with functions for this kind of stuff ? Or maybe we should just wait for Microsoft to provide a better way of dealing with Extension Ids (or maybe they plan to not use Ids in the future) ?

You can find these scripts also on my GitHub:
https://github.com/andreilungu/Utilities/tree/master/Powershell
Filename: 001_GetALExtensionIDandObjectName.ps1

*Later Edit:
In the meantime I created a small Powershell module to help you get information about AL Extension Files. You can read

Running a Container-Based Development Environment

Original URL…

Dynamics 365 Business Central is available as a container-based image, ready for running on a Windows system with Docker installed. The container-based approach is used when you need access to both the AL development environment and the C/SIDE development environment.

Install and configure Docker

Install Docker and configure it for Windows Containers. Please choose the version of Docker that is appropriate for the host operating system.

Run the container-based image

Run the following command in a Command Prompt as Administrator to run a Docker image of Dynamics 365 Business Central:

docker run -e accept_eula=Y -m 4G microsoft/dynamics-nav

Note

When you run the Docker run command, it will start downloading the image if it does not already exist. A container consists of multiple layers, only the needed layers are downloaded.

At this point, you can open your internet browser and type in the Web client URL. You will be prompted with a login dialog, where you can login with the NAV Admin Username/Password displayed.

The NavContainerHelper module

To support the use of containers, optional PowerShell scripts are available, which support setup of development environments. Use the NavContainerHelper to work with containers. On a Windows 10 or Windows Server 2016, start Powershell as an Administrator and type:

install-module navcontainerhelper -force

To see which functions are available in the NavContainerHelper module use the following command:

Write-NavContainerHelperWelcomeText

To get quickly get started, run the following command from the NavContainerHelper module:

new-navcontainer -accept_eula -containerName test -imageName microsoft/dynamics-nav:devpreview

The NavContainerHelper will create a folder on the C:\ drive called DEMO and will place all files underneath that folder. The DEMO folder will be shared to the container for transfer of files etc. If you do not specify a username and a password, it will ask for your password and use the current Windows username. If you specify your windows password, the container setup will use Windows Authentication integrated with the host. The NavContainerHelper will also create shortcuts on the desktop for the Dynamics 365 Business Central Web client, a container prompt, and a container PowerShell prompt.

The navcontainerhelper module also allows you to add the -includeCSide switch in order to add the Dynamics 365 Business Central Windows client and C/SIDE to the desktop and export all objects to a folder underneath C:\DEMO\Extensions for the object handling functions from the module to work.

See Also

Getting Started with AL
Keyboard Shortcuts
AL Development Environment
FAQ for Developing in AL

More Cross-Platform APIs with Xamarin.Essentials Latest Preview

Original URL…

We announced Xamarin.Essentials, a core set of cross-platform APIs to help developers build native apps, at Microsoft Build 2018. Xamarin.Essentials gives developers access to over thirty platform-specific APIs that can be accessed from their shared code, including geolocation, secure storage, sensors, device information, and many more. Best of all, Xamarin.Essentials can be used in any iOS, Android, UWP, or Xamarin.Forms app, regardless of how you create the user interface. Feedback on the first preview from developers has been fantastic, with praise of a simple and straightforward way to access these native features.

Today, we are pleased to release our second preview of Xamarin.Essentials (0.7.0-preview), which is available today on NuGet. This release combines feedback from developers, bug fixes, and several new APIs that you can take advantage of today.

Orientation Sensor

Xamarin.Essentials first release gave developers access to the accelerometer, gyroscope, magnetometer, and compass. Based on your feedback, we’ve added an API for the orientation sensor. This API allows you to subscribe to reading changes that are reported back as a Quaternion, which describes rotation of the Earth’s coordinate system relative to the device’s coordinate system. This is extremely useful when creating applications that need access to 3D space.

 

…View Code

MainThread APIs

When developing applications that process information in the background, it’s important to update the user interface on the main thread. With the MainThread API, you now have access to detect if you’re currently on the main thread and also begin an update on the main thread. We use this API internally to optimize our own code in Xamarin.Essentials.

…View Code

Simplified Android Dependencies

Based on your feedback, Xamarin.Essentials is now built against Android 8.1 (API 27), with the updated dependencies of two Android Support libraries, CustomTabs and Core.Utils. This means you will need to ensure you have your Xamarin.Android project set to compile against Android 8.1 (API 27), which you can set in the properties of your project.

Remember, it’s important to have the saved version of all Android Support libraries in your project; now is a good time to update all of your dependencies in your project.

Xamarin.Essentials In Action

Ready to learn more about Xamarin.Essentials? Look no further than the latest Xamarin Show: Snack Pack, which gives a full overview of Xamarin.Essentials and how to start integrating it into your app.

Learn More

Read more about this release in our full release notes and be sure to browse through our full documentation, which has a full overview of how to get started and how to use every feature of Xamarin.Essentials.