In the previous post, Setting up Dynamics NAV 2018 for Testing and Development in Docker we have covered how to setup a development and testing environment, and had our first steps with Visual Studio Code to publish our first hello world application.

Now I want to show you some AL language thing that might be useful. You can see them in action in the example app ALBasics: https://github.com/TBits/Al-examples/tree/master/ALBasics

There are test procedures illustrating how to:

  • Working with basic constructs like “if”
  • Format various types of variables to string (known as Text), using Format(), or StrSubstNo().
  • Parse Integer to String with Evaluate()
  • Working with Date and DateTime, getting the current Now with CurrentDateTime or Today with Today. Comparing dates, even by a given difference in for example days, with CalcDate(). Converting between DateTime and Date, with DT2Time(), and setting a date with DMY2DATE().
  • How to work with options: calling a procedure with an option parameter, and the issues you can get if you have different definitions of the options.
  • How to call procedures with reference parameters (keyword var), and how to return a result either by a named variable or with exit(<value>)
  • How to call a procedure that is defined inside a code unit.
Tags: ,
Posted in Software Development | Comments Closed

In the past months, I have learned a lot about Dynamics NAV 2018. There are some examples available on the net, but not enough. So I will provide some examples on my blog.

Let’s start with setting up the free Docker container on Windows of Dynamics NAV for testing and development purposes.

My first obstacle was the requirements to the CPU.

First, you need a CPU with SLAT for running Hyper-V on Windows 10. See also https://social.technet.microsoft.com/wiki/contents/articles/1401.hyper-v-list-of-slat-capable-cpus-for-hosts.aspx which states: “Every Core i3, i5 and i7 supports SLAT. You can look up the supported AMD versions at KB article on AMD“.
So I bought a refurbished HP ProBook 6560b with a Intel Core i5-2520M CPU, but that did not work. It does not support docker images with more than 2 GB of RAM. But you need 4 GB to run Dynamics NAV 2018 in a container. See this bug for more details: https://github.com/docker/for-win/issues/1094.
With the coreinfo tool (download here for free: https://docs.microsoft.com/en-us/sysinternals/downloads/coreinfo), you can test if your CPU is supported:

Coreinfo.exe -f

If you see a star, then you should be fine.

PAGE1GB * Supports 1 GB large pages

If you see a hyphen, then you cannot use that computer:

PAGE1GB - Supports 1 GB large pages

You can install Docker for Windows from https://www.docker.com/docker-windows. You need to register in the Docker Hub for free. You install it, and it will ask you to restart the computer, the latest version enables Hyper-V, and it asks if you want to use Linux or Windows containers. Let the installer prepare your computer for Windows containers.

When you start Docker, and right click on the symbol, you see Kitematic. That is a useful tool to manage your containers graphically. Click on it, and it will download a zip file. Extract the contents to C:\Program Files\Docker\Kitematic.

The docker images from Microsoft are listed here: https://hub.docker.com/r/microsoft/dynamics-nav/

As administrator you open a PowerShell, and run these commands:

# this should pull the latest dynamics-nav, 2018 at the moment
docker pull microsoft/dynamics-nav
# now start a container
docker run -e accept_eula=Y -e ClickOnce=Y -e UseSSL=N -m 4G microsoft/dynamics-nav

I chose the setting ClickOnce=Y because I wanted to test not only the web client, but also the Windows Client.

I chose the UseSSL=N setting because I had issues with Visual Studio Code to download the symbols or to upload my extension if it Dynamics NAV was installed with a self-signed certificate. I got the message:

Die zugrunde liegende Verbindung wurde geschlossen: Für den geschützten SSL/TLS-Kanal konnte keine Vertrauensstellung hergestellt werden..
Das Remotezertifikat ist laut Validierungsverfahren ungültig.

You probably could download the certificate from http://YOURCONTAINERIP:8080/certificate.cer and install it into your “Trusted Root Certification Authorities” but I did not want to do that just for testing purposes.

This is the output of the docker run command:

PS C:\WINDOWS\system32> docker run -e accept_eula=Y -e ClickOnce=Y -e UseSSL=N -m 4G microsoft/dynamics-nav
Initializing...
Starting Container
Hostname is c63405985172
PublicDnsName is c63405985172
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 5D0E6813F13AA90A59328F196F9594CCEF3F1DF9
Modifying Service Tier Config File with Instance Specific Settings
Starting NAV Service Tier
Creating DotNetCore Web Server Instance
Creating http download site
Creating Windows user admin
Setting SA Password and enabling SA
Creating admin as SQL User and add to sysadmin
Creating SUPER user
Creating ClickOnce Manifest
Container IP Address: 172.17.43.185
Container Hostname  : c63405985172
Container Dns Name  : c63405985172
Web Client          : http://c63405985172/NAV/
NAV Admin Username  : admin
NAV Admin Password  : Qake5494
Dev. Server         : http://c63405985172
Dev. ServerInstance : NAV
ClickOnce Manifest  : http://c63405985172:8080/NAV

Files:
http://c63405985172:8080/al-0.12.25327.vsix

Initialization took 114 seconds
Ready for connections!

Now how to test your Dynamics NAV instance:

    • Web Client: you see the URL in the output above. It will be different in your installation…
    • Windows Client: it does not work in Firefox, to download the ClickOnce manifest from the URL mentioned above, installing it gives the error: System.Deployment.Application.InvalidDeploymentException (Zone)
      – Die Bereitstellung und die Anwendung haben keine übereinstimmenden Sicherheitszonen.
      But it works in Edge or Internet Explorer just fine. You use the NAV Admin Username and Password as specified in the docker output.
    • With Visual Studio Code: Install the AL Language extension from http://c63405985172:8080/, the file is called like al-0.12.25327.vsix. In Visual Studio Code, go to Extension, select the hamburger menu at the top, and choose “Install from VSIX file”. Installing the AL Language extension from the Marketplace would install a newer version of the extension, but it probably causes issues with your server because it is not compatible.

First steps with Visual Studio Code: Create a sample application: Ctrl-Shift-P, search for AL:Go!, and run it. This will ask you where you want the project stored, and then create a hello world example.

You need to modify the file launch.json, and enter for server the URL which was in the docker output labelled as “Dev. Server”, in my case “http://c63405985172”

Then you can press Ctrl-Shift-P, search for AL: Download Symbols, and run that.

After the symbols have been downloaded, run AL: Publish, which should first ask your for your username and password (use admin and the password from the docker output), then it will upload your extension to the NAV server, and VS Code will start the Web client with the page Contacts, because that page is the Object ID 22, which is defined in startupObjectId in launch.json. You will see the message box.

I have submitted this basic extension on Github: https://github.com/TBits/Al-examples/tree/master/HelloWorld

In the next post in this series, we will discover the AL language in more detail: Getting used to the AL language for Dynamics NAV 2018

 

In the past weeks, I have been working on a deployment of Dynamics NAV 2018. This is quite a change for me, to work again on a Windows machine, and with closed source software. Fortunately, there are already some resources on the web, eg. Powershell scripts by Waldo: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell/tree/master/PSScripts

Today, I want to publish some basic Batch scripts that help our team to start our development environment. In our setup, we have a normal unprivileged Windows user. But we need a privileged user for access to the Dynamics NAV Server. Lets assume that the privileged user has a suffix called -p for privileged.

startDynamicsNAVClient.bat

This script will just start the Dynamics NAV 2018 client, running as the privileged user.

@echo off
runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe -settings:\\files\ERP\RTCCONFIG\DEV110_NST01_V103.config"

startDynamicsNAVIDE.bat

This script will start the Dynamics NAV IDE, which we use mainly for the Object Designer. We need the parameter generatesymbolreference, so that the symbols will be generated when we compile the C/AL code, so that the symbols are available for AL development in VS Code.

It seems we have some issue with localization, some users need Ja (german culture), others need Yes as the value for generatesymbolreference.

@echo off
REM runs the Dynamics NAV IDE (Object Designer)
REM some users have to use generatesymbolreference=Ja others need generatesymbolreference=Yes
REM we try to determine the language settings by the variable HomePath: Users vs Benutzer
set "generatesymbolreference=Ja"
if "%ProgramFiles%" equ "C:\Program Files" (SET /A generatesymbolreference=Yes)
runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\finsql.exe generatesymbolreference=%generatesymbolreference%"

startDynamicsNAVShell.bat

This script starts a PowerShell with the right startup parameters, so that some specific modules will be preloaded for development of Dynamics NAV. This seems to be quite tricky, to start PowerShell with another user. So we call the Batch script again as the different user, in order to be able to start PowerShell as that user.

@echo off
REM start the DynamicsNAV Development PowerShell
SET mypath=%~dp0
echo %mypath%
IF "%USERNAME:~-2%" neq "-p" (
  runas /user:"MYDOMAIN\%USERNAME%-p" "%mypath%\startDynamicsNAVShell.bat"
) else (
  cd C:\Users\%USERNAME%\DEV
  C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.exe  -NoExit -ExecutionPolicy RemoteSigned " &amp; ' C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\NavModelTools.ps1 ' "
)

startVSCode.bat

Last, but not least: we start VSCode as a different user.

@echo off
start runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files\Microsoft VS Code\Code.exe"
Tags: , ,
Posted in Software Development | Comments Closed

Here comes a quick overview on recent updates to Kolab 16 packages.

Please note: I am only using public information. I have no background knowledge about the releases.

In the past days, the following packages have been updated:

Tags: ,
Posted in Hosting, Software Development | Comments Closed

Here comes a quick overview on recent updates to Kolab 16 packages.

Please note: I am only using public information. I have no background knowledge about the releases.

In the past days, the following packages have been updated:

Because of these changes, the following packages have been rebuilt as well: kolab-freebusy, iRony

Tags: ,
Posted in Hosting, Software Development | Comments Closed

This is an updated version of the post from July 2015: https://www.pokorra.de/2015/07/submitting-patches-to-kolab-via-phabricator/

For a description of phabricator, see the post from July 2015.

Here are the updated instructions for using arcanist with CentOS7:

yum install git vim php-cli python-pep8
# this does not work because of contradicting dependancies:
# wget https://obs.kolabsys.com/repositories/Tools/CentOS_7/Tools.repo -O /etc/yum.repos.d/kolab-tools.repo
# yum install arcanist
git clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.git
export PATH=$PATH:/root/arcanist/bin/
arc set-config default https://git.kolab.org
arc install-certificate 
# go to https://git.kolab.org/conduit/login/ and copy the token and paste it to arc

Now get the repository you want to work with, eg. pykolab:

export PATH=$PATH:/root/arcanist/bin/
git clone https://git.kolab.org/diffusion/P/pykolab.git
cd pykolab
# do your changes
# vi pykolab/auth/ldap/__init__.py
git commit -a
arc diff            # Creates a new revision out of ALL unpushed commits on
                    # this branch.

Now you have a new Differential revision, in my example at: https://git.kolab.org/D559

Tags: ,
Posted in Hosting, Software Development | Comments Closed

Today, one of our customers at TBits.net noticed that when composing an e-mail in Roundcube, there is a spell checker button at the top. But only for English, and when there was text in the e-mail, and he clicked on the spell check button, he got the message: “An error was encountered on the server. Please try again later.”

I found the cause in the Roundcube log file, in /var/log/roundcubemail/errors:

PHP Error: Spell check engine error: Pspell extension not available in /usr/share/roundcubemail/program/steps/utils/spell.inc on line 50

So I installed the required packages:

yum install php-pspell aspell-de
systemctl restart httpd

Now this works for English. It seems for German and other languages, there are no packages readily available in the repositories.
I checked https://apps.fedoraproject.org/packages/aspell-de, there are packages for Fedora, but not for EPEL.

So you go to https://ftp.gnu.org/gnu/aspell/dict/0index.html#0.60 and download the dictionary for your language, and install it like this on your Kolab server:

tar xjf aspell6-de-20030222-1.tar.bz2
cd aspell6-de-20030222-1
./configure
make
make install

Now do a reload in Roundcube, and now you can check your spelling even in German!

 

Update: It was suggested by Luca Berra from Italy, to use enchant and hunspell instead of pspell/aspell.

For a discussion of hunspell vs aspell, see http://penguindreams.org/blog/aspell-and-hunspell-a-tale-of-two-spell-checkers/

Luca gave me these instructions:

yum install php-enchant hunspell-it
 
vi /etc/roundcubemail/config.inc.php
    $config['spellcheck_engine'] = 'enchant';

I have not tested this. Thanks to Luca for this suggestion!

Tags: ,
Posted in Hosting, Software Development | Comments Closed

Various updated packages in Kolab 16   November 17th, 2017

Here comes a quick overview on recent updates to Kolab 16 packages.

Please note: I am only using public information. I have no background knowledge about the releases.

In the past days, the following packages have been updated:

Because of these changes, the following packages have been rebuilt as well: php-sabre-dav, kolab-syncroton, kolab-freebusy, iRony, pykolab, kolab-utils, libkolab.

Tags: ,
Posted in Hosting, Software Development | Comments Closed

Here comes a quick overview on recent updates to Kolab 16 packages.

Please note: I am only using public information. I have no background knowledge about the releases.

Today, the roundcubemail package has been updated from version 1.3.0.41 to 1.3.3. This fixes a security issue, described in https://roundcube.net/news/2017/11/08/security-updates-1.3.3-1.2.7-and-1.1.10. Also see the release notes https://roundcube.net/news/2017/09/04/update-1.3.1-released and https://roundcube.net/news/2017/10/31/update-1.3.2-released for new changes.
Because of this, the packages iRony, kolab-freebusy and kolab-syncroton have been rebuilt as well.

In the past days, erlang-eimap has been updated with a patch for untagged commands. Because of that, guam has also been rebuilt. For details see https://obs.kolabsys.com/package/rdiff/Kolab:16/erlang-eimap?linkrev=base&rev=8

Tags: , ,
Posted in Hosting, Software Development | Comments Closed

Ansible with su instead of sudo   October 13th, 2017

At TBits.net, we have decided to use Ansible for setting up our servers.

The most documented way of installing something on a machine via Ansible is using sudo: you create a normal user (eg. called deploy), that you can use with SSH to login to the machine, and if that user has sudo permissions (eg. part of the group wheel in CentOS), then you can install software with root privileges.

The call is quite easy:

ansible-playbook myplaybook.yaml --user=deploy --ask-become-pass

Now we wanted to limit access only to users who have the actual password for root.

Finally, this worked on the command line:

ansible-playbook myplaybook.yaml --user=deploy --become --become-method=su --ask-become-pass

Now, I wanted to specify these parameters in my ansible.cfg file. It took me a while to find out how to do this. I found https://github.com/ansible/ansible/blob/devel/lib/ansible/config/base.yml which was helpful.

[defaults]
remote_user=deploy
 
[privilege_escalation]
become = true
become_method = su
become_ask_pass = true

Two pitfalls that are solved by this:

  • You need to specify the become settings in section privilege_escalation, not just in defaults.
  • The command line parameter ask-become-pass becomes become_ask_pass in the config file.

This works with Ansible 2.3.2 on CentOS 7.4.

Tags: ,
Posted in Hosting, Software Development | Comments Closed