Cannot login to Microsoft Dynamics Business Central 2019 Spring release (BC14) RTM with LoginName authentication

Dynanmics 365 Business Central logo

Have you tried to configure a Microsoft Dynamics Business Central 2019 Spring release (BC14) RTM with LoginName authentication, just to find that it did not work?

You are right.

You won’t be able to login to the Web- or Windows-client and will get errors in your event log like these:

Server instance: BC140
Category: Runtime
ClientSessionId: 1396b6cf-5cfd-4dae-b98a-9ee3a6d3d3e1
ClientActivityId: 8665e7ca-3a27-49f3-b928-4a013317be94
ServerSessionUniqueId: 00000000-0000-0000-0000-000000000000
ServerActivityId: 5d8ecef1-6d64-4d05-9031-03a0248c9138
EventTime: 08/09/2019 10:14:40
Message (NullReferenceException): RootException: NullReferenceException

Object reference not set to an instance of an object.

ExceptionStackTrace:
   at Microsoft.Dynamics.Nav.Service.NSServiceBase.<>c__DisplayClass14_0.b__0()
   at Microsoft.Dynamics.Nav.Service.NSServiceBase.ValidateAndCreateSession(ConnectionRequest connectionRequest, Boolean requireNavUser)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)

CallerStackTrace:
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass27_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationTracer.TraceScopeCombinator(Category telemetryCategory, ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass27_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass9_0.b__0()
   at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationDuration(Stopwatch stopWatch, Action action)
   at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationAction(Action action, NavSession session)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.PerformanceCounterCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass27_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.InitClientTelemetryIdsCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass27_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TlsClearCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass27_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
   at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
   at System.ServiceModel.Dispatcher.MessageRpc.Wrapper.Resume(Boolean& alreadyResumedNoLock)
   at System.ServiceModel.Dispatcher.ThreadBehavior.ResumeProcessing(IResumeMessageRpc resume)
   at Microsoft.Dynamics.Nav.Runtime.NavSynchronizationContext.<>c__DisplayClass1_0.b__0(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
Server instance: BC140
 Tenant ID: 
 User: xxx
 Type: System.NullReferenceException
 Message: Object reference not set to an instance of an object.
 StackTrace:
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.<>c__DisplayClass14_0.b__0()
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.ValidateAndCreateSession(ConnectionRequest connectionRequest, Boolean requireNavUser)
      at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)
 Source: Microsoft.Dynamics.Nav.Service
 HResult: -2147467261
 StackTrace:
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.<>c__DisplayClass14_0.b__0()
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.ValidateAndCreateSession(ConnectionRequest connectionRequest, Boolean requireNavUser)
      at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)
Type: Microsoft.Dynamics.Nav.Client.NavClientClosingException
 Fatal: False
 ShowError: True
 Message: The server "BC140" was unable to process the request. The application will close.
 StackTrace:
      at Microsoft.Dynamics.Nav.Client.WinClient.ExceptionHandler.DoExecute(Func1 execute)      at Microsoft.Dynamics.Nav.Client.WinClient.StartWinFormsClient.RunCore() Source: Microsoft.Dynamics.Nav.Client.WinClient HResult: -2146233088 StackTrace:      at Microsoft.Dynamics.Nav.Client.WinClient.ExceptionHandler.DoExecute(Func1 execute)
      at Microsoft.Dynamics.Nav.Client.WinClient.StartWinFormsClient.RunCore()
 Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavServerSessionException
 Message: The server "BC140" was unable to process the request. The application will close.
 StackTrace:
      at Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.OpenConnection[TChannel](ConnectFailedEventArgs connectFailedArgs, ConnectionRequest connectionRequest, ConnectionOptions connectionOptions, SpnSetting spnSettingToTry, Boolean allowSpnSettingsSwap, UserSettings& userSettings)
      at Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.OpenConnection[TChannel](ConnectionRequest connectionRequest, ConnectionOptions connectionOptions, UserSettings& userSettings)
      at Microsoft.Dynamics.Nav.Client.ServiceConnection.OpenConnection()
      at Microsoft.Dynamics.Nav.Client.ServiceConnection.Initialize()
      at Microsoft.Dynamics.Nav.Client.FormBuilder.BuilderSessionInitializer.OpenConnectionToServer()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.OpenServerConnectionCore()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.OpenServerConnectionWithMultipleLoginAttempts()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.InitializeUISession()
      at Microsoft.Dynamics.Framework.UI.Windows.ClientSessionBase.InitCore()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.InitCore()
      at Microsoft.Dynamics.Framework.UI.ClientSessionCore.Init()
      at Microsoft.Dynamics.Framework.UI.Windows.ClientSessionBase.Run()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavClientErrorHandler.ExecuteAndCatchExceptions(Func`1 execute)
 Source: Microsoft.Dynamics.Nav.Client.ServiceConnection
 HResult: -2146233088
 StackTrace:
      at Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.OpenConnection[TChannel](ConnectFailedEventArgs connectFailedArgs, ConnectionRequest connectionRequest, ConnectionOptions connectionOptions, SpnSetting spnSettingToTry, Boolean allowSpnSettingsSwap, UserSettings& userSettings)
      at Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.OpenConnection[TChannel](ConnectionRequest connectionRequest, ConnectionOptions connectionOptions, UserSettings& userSettings)
      at Microsoft.Dynamics.Nav.Client.ServiceConnection.OpenConnection()
      at Microsoft.Dynamics.Nav.Client.ServiceConnection.Initialize()
      at Microsoft.Dynamics.Nav.Client.FormBuilder.BuilderSessionInitializer.OpenConnectionToServer()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.OpenServerConnectionCore()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.OpenServerConnectionWithMultipleLoginAttempts()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.InitializeUISession()
      at Microsoft.Dynamics.Framework.UI.Windows.ClientSessionBase.InitCore()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavWinFormsClientSession.InitCore()
      at Microsoft.Dynamics.Framework.UI.ClientSessionCore.Init()
      at Microsoft.Dynamics.Framework.UI.Windows.ClientSessionBase.Run()
      at Microsoft.Dynamics.Nav.Client.WinClient.NavClientErrorHandler.ExecuteAndCatchExceptions(Func`1 execute)
 Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavServerSessionException
 Message: The server "BC140" was unable to process the request. The application will close.
 HResult: -2146233088
 Type: System.NullReferenceException
 Message: Object reference not set to an instance of an object.
 StackTrace:
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.<>c__DisplayClass14_0.b__0()
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.ValidateAndCreateSession(ConnectionRequest connectionRequest, Boolean requireNavUser)
      at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)
 Source: Microsoft.Dynamics.Nav.Service
 HResult: -2147467261
 StackTrace:
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.<>c__DisplayClass14_0.b__0()
      at Microsoft.Dynamics.Nav.Service.NSServiceBase.ValidateAndCreateSession(ConnectionRequest connectionRequest, Boolean requireNavUser)
      at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)

Part of the story is that the same setup simply works with earlier versions, and that Windows-authentication also works without any glitches.

At least the fix is simple: Upgrade your platform to Cumulative Update 1 (or actually I recommend the latest while you are at it anyway 🙂 ).

Note, the error is also mentioned on forum.mibuso.com here!

Thanks goes to Christoph Bendixen and Jesper Dahl Fredriksen from team.blue aka ScanNet.dk for helping reporting and identifying this problem.

Playing around with the DynamicsNAV:// protocol handler

Dynanmics 365 Business Central logo

If you have been using the Dotnet ClickOnce technology to roll out your Dynamics NAV / 365 Business Central Windows Clients, you know it have some limitations (click here to read all about the limitations).

But if you start pulling the ClickOnce technology apart, you will find that the client files are in fact present on your harddrive, but in a obscure directory – which can be hard to locate (actually you can just start the client and go to task manager. Right click the running program and select to open the directory).

What if someone could make a small program or script that would locate all installed ClickOnce Dynamics NAV / 365 Business Central Windows Clients, present you with a list to choose from and then simply start the selected client with the appropriate parameters?

Maybe we can even register this small program or script as the protocol handler for the DynamicsNAV:// protocol?

Well, here is my first attempt of a PowerShell script I call NAVBCProtocolHandlerHelper.ps1 :-):

# Version: 2019-08-06

$SearchPath = "C:\Users\$($env:UserName)\AppData\Local\Apps\2.0\"

$WindowsClientFileName = "Microsoft.Dynamics.Nav.Client.exe"
$ClientUserSettingsFileName = "ClientUserSettings.config"

if(($args[0] -eq "?") -or ($args[0] -eq "-?") -or ($args[0] -eq "-h") -or ($args[0] -eq "-help")) {
  Write-Host "#######################################################################" -ForegroundColor Cyan
  Write-Host "# Microsoft Dynamics NAV/365 Business Central Protocol Handler Helper #" -ForegroundColor Cyan
  Write-Host "#######################################################################" -ForegroundColor Cyan
  Write-Host "#             Copyright 2019, Gert Lynge, www.dabbler.dk              #" -ForegroundColor Cyan
  Write-Host "#######################################################################" -ForegroundColor Cyan
  Write-Host "# This script is free to use, modify and distribute as long as these  #" -ForegroundColor Cyan
  Write-Host "# lines are kept intact. NO WARRANTY! Use at your own risk!           #" -ForegroundColor Cyan
  Write-Host "#######################################################################" -ForegroundColor Cyan
  Write-Host ""
  Write-Host "Examples:" -ForegroundColor Cyan
  Write-Host ""
  Write-Host "Install NAV/365BC Protocol Handler:" -ForegroundColor Cyan
  Write-Host "$($MyInvocation.MyCommand.Definition) -InstallProtocolHandler"
  Write-Host "Be warned: This will override any existing DynamicsNAV:// protocol handler" -ForegroundColor Red
  Write-Host ""
  Write-Host "Remove NAV/365BC Protocol Handler:" -ForegroundColor Cyan
  Write-Host "$($MyInvocation.MyCommand.Definition) -RemoveProtocolHandler"
  Write-Host "Be warned: This will remove any DynamicsNAV:// protocol handler installed" -ForegroundColor Red
  Write-Host ""
  Write-Host "Show list of NAV/365BC ClickOnce Windows Clients and let you select one to start:" -ForegroundColor Cyan
  Write-Host "$($MyInvocation.MyCommand.Definition)"
  Write-Host ""
  Write-Host "Show this help page:" -ForegroundColor Cyan
  Write-Host "$($MyInvocation.MyCommand.Definition) -help"
  exit
}
elseif(($args[0] -eq "InstallProtocolHandler") -or ($args[0] -eq "-InstallProtocolHandler")) {
  $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  if(-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Throw "Installing the DynamicsNAV:// Protocol handler requires this script to be run as Administrator"
  }

  New-PSDrive -Name HKCR -PSProvider Registry -Root "HKEY_CLASSES_ROOT" -ErrorAction SilentlyContinue | Out-Null
  New-Item -Path "HKCR:\DynamicsNAV" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV" -Name "(Default)" -Value "Dynamics NAV Protocol" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV" -Name "URL Protocol" -Force | Out-Null

  New-Item -Path "HKCR:\DynamicsNAV\DefaultIcon" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV\DefaultIcon" -Name "(Default)" | Out-Null

  New-Item -Path "HKCR:\DynamicsNAV\Shell" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV\Shell" -Name "(Default)" | Out-Null

  New-Item -Path "HKCR:\DynamicsNAV\Shell\Open" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV\Shell\Open" -Name "(Default)" | Out-Null

  New-Item -Path "HKCR:\DynamicsNAV\Shell\Open\Command" -Force | Out-Null
  New-ItemProperty -Path "HKCR:\DynamicsNAV\Shell\Open\Command" -Name "(Default)" -Value "PowerShell.exe -WindowStyle Hidden -File ""$($MyInvocation.MyCommand.Definition)"" ""%1""" | Out-Null

  Write-Host "Protocol Handler DynamicsNAV:// installed" -ForegroundColor Green
  exit
}
elseif(($args[0] -eq "RemoveProtocolHandler") -or ($args[0] -eq "-RemoveProtocolHandler")) {
  $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  if(-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Throw "Removing the DynamicsNAV:// Protocol handler requires this script to be run as Administrator"
  }

  New-PSDrive -Name HKCR -PSProvider Registry -Root "HKEY_CLASSES_ROOT" -ErrorAction SilentlyContinue | Out-Null
  Remove-Item -Path "HKCR:\DYNAMICSNAV" -Recurse -Force | Out-Null

  Write-Host "Protocol Handler DynamicsNAV:// removed" -ForegroundColor Green
  exit
}


$WindowsClients = New-Object System.Data.DataTable
$WindowsClients.Columns.Add("Product","System.String") | Out-Null
$WindowsClients.Columns.Add("Server","System.String") | Out-Null
$WindowsClients.Columns.Add("Port","System.String") | Out-Null
$WindowsClients.Columns.Add("Instance","System.String") | Out-Null
$WindowsClients.Columns.Add("Tenant","System.String") | Out-Null
$WindowsClients.Columns.Add("Authentication","System.String") | Out-Null
$WindowsClients.Columns.Add("Version","System.Version") | Out-Null
$WindowsClients.Columns.Add("Path","System.String") | Out-Null

foreach($File in Get-ChildItem -Path "$SearchPath$WindowsClientFileName" -Recurse | Select-Object FullName) {
  $Path = (Split-Path -Path $File.FullName -Parent)

  if(Test-Path "$Path\$ClientUserSettingsFileName" -PathType Leaf) {
    [xml]$XmlDocument = Get-Content -Path "$Path\$ClientUserSettingsFileName"
    $ChildNodes = $XmlDocument.configuration.appSettings.ChildNodes

    $WindowsClient = $WindowsClients.NewRow()
    $WindowsClient.Path = $Path
    $WindowsClient.Version = [System.Version][System.Diagnostics.FileVersionInfo]::GetVersionInfo($File.FullName).FileVersion
    $WindowsClient.Server = ($ChildNodes | Where-Object {($_.key -eq "Server")}).value
    $WindowsClient.Port = ($ChildNodes | Where-Object {($_.key -eq "ClientServicesPort")}).value
    $WindowsClient.Instance = ($ChildNodes | Where-Object {($_.key -eq "ServerInstance")}).value
    $WindowsClient.Tenant = ($ChildNodes | Where-Object {($_.key -eq "TenantId")}).value
    $WindowsClient.Authentication = ($ChildNodes | Where-Object {($_.key -eq "ClientServicesCredentialType")}).value
    $WindowsClient.Product = ($ChildNodes | Where-Object {($_.key -eq "ProductName")}).value
    $WindowsClients.Rows.Add($WindowsClient)
  }
}
$WindowsClients = $WindowsClients | Group-Object -Property Server,ClientServicesPort,ServerInstance,TenantId | `
                  foreach { $_.Group | Sort-Object @{Expression="Version";Descending="$True"} | Select-Object -First 1 }

$Picked = $WindowsClients | Out-GridView -PassThru -Title "Select which Microsoft Dynamics NAV/365 Business Central ClickOnce Windows Client to run"

if(-not $Picked) {
  exit
}

$Command = "$($Picked.Path)\$WindowsClientFileName"
if($args[0]) {
  & "$Command" "-protocolhandler" $args[0]
}
else {
  & "$Command"
}

Please run NAVBCProtocolHandlerHelper.ps1 from a powershell CLI with the -help parameter and read the possibilities. It has five ways of running:

  1. Show the help:
    NAVBCProtocolHandlerHelper.ps1 -help
  2. Install itself as the DynamicsNAV:// protocol handler (OVERWRITING the existing one):
    NAVBCProtocolHandlerHelper.ps1 -InstallProtocolHandler
  3. Remove ANY DynamicsNAV:// protocol handler (also ones the script did not install itself):
    NAVBCProtocolHandlerHelper.ps1 -RemoveProtocolHandler
  4. Show list of installed ClickOnce Windows Clients for Dynamics NAV/365 Business Central and lets you choose one. The chosen one is started:
    NAVBCProtocolHandlerHelper.ps1
  5. Started through the DynamicsNAV:// protocol.
    A list of installed ClickOnce Windows Clients for Dynamics NAV/365 Business Central will be shown. When you chose one, it is started and the URL is passed as a parameter to it (just like if it was called directly from the protocol handler):
    DynamicsNAV://<your parameters>

This is still work in progress and can be improved in many ways. Feel free to send me your comments and wishes.

You can use and modify this free of charge as long as you keep the blocks shown in the help intact.
This is completely without any warranty of any kind – so use at your own risk!
Parameters and functionalities are subject to changes as this is work in progress.

Option value != OptionML value

Dynanmics 365 Business Central logo

Do you need some way of getting the Option value instead of the OptionML value from an Option field?

It is not so straight forward as one should think, but with this simple function the work is done for you:

PROCEDURE GetOptionValue@1000000002(TableId@1000000001 : Integer;FieldId@1000000000 : Integer;Value@1000000002 : Integer) : Text;
VAR
  TableRef@1000000003 : RecordRef;
  FieldRef@1000000004 : FieldRef;
BEGIN
  //Example:
  //  MESSAGE(KMCTools.GetOptionValue(DATABASE::"Sales Line",SalesLine.FIELDNO(Type),SalesLine.Type::Item));
  TableRef.OPEN(TableId);
  FieldRef := TableRef.FIELD(FieldId);
  EXIT(SELECTSTR(Value+1,FieldRef.OPTIONSTRING));
END;

Free of charge – but use on your own risk…

Microsoft Dynamics 365 Business Central WebClient with no Role Center

Dynanmics 365 Business Central logo

Is your Microsoft Dynamics 365 Business Central Windows Client working, but your Web Client gets stuck with this picture just after log in?

WebClient - no Role Center
WebClient – stuck with no Role Center just after login.

…and do you see events like these in the Windows eventviewser on the Server? (sorry – I know it is in Danish: “fejl” translates to “error” and “undtagelse” means “exception”)

Der opstod fejl under forsøg på adgang til webstedet 
Type: Microsoft.Dynamics.Nav.Types.NavCancelCredentialPromptException
Message: Der blev udløst en undtagelse af typen 'Microsoft.Dynamics.Nav.Types.NavCancelCredentialPromptException'.
StackTrace:
   ved Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.PromptForCredentials() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.ServiceConnection\ConnectionEstablisher.cs:linje 1041
   ved Microsoft.Dynamics.Nav.Client.ConnectionEstablisher.OpenConnection[TChannel](ConnectionRequest connectionRequest, ConnectionOptions connectionOptions, UserSettings& userSettings) i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.ServiceConnection\ConnectionEstablisher.cs:linje 196
   ved Microsoft.Dynamics.Nav.Client.ServiceConnection.OpenConnection() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.ServiceConnection\ServiceConnection.cs:linje 892
   ved Microsoft.Dynamics.Nav.Client.ServiceConnection.Initialize() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.ServiceConnection\ServiceConnection.cs:linje 561
   ved Microsoft.Dynamics.Nav.Client.FormBuilder.BuilderSessionInitializer.OpenConnectionToServer() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.Builder\BuilderSession\BuilderSessionInitializer.cs:linje 265
   ved Microsoft.Dynamics.Nav.Client.FormBuilder.BuilderSessionInitializer.InitializeCore() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.Builder\BuilderSession\BuilderSessionInitializer.cs:linje 92
   ved Microsoft.Dynamics.Nav.Client.FormBuilder.BuilderSessionInitializer.Initialize() i S:\Depot\Platform-Core\platform\client\Shared\Prod.Client.Builder\BuilderSession\BuilderSessionInitializer.cs:linje 76
   ved Microsoft.Dynamics.Framework.UI.UISession.Initialize() i S:\Depot\Platform-Core\platform\client\Shared\Prod.ClientFwk\Session\UiSession.cs:linje 1094
   ved Microsoft.Dynamics.Nav.Client.Web.NavWebUISessionInitializer.InitializeCore(UISession session) i S:\Depot\Platform-Core\platform\client\web\Prod.Client.WebCommon\Session\NavWebUISessionInitializer.cs:linje 94
   ved Microsoft.Dynamics.Nav.WebClient.NavWebClientUISessionInitializer.InitializeCore(UISession session) i S:\Depot\Platform-Core\platform\client\web\Prod.Client.WebClient\Session\NavWebClientUISessionInitializer.cs:linje 65
   ved Microsoft.Dynamics.Nav.Client.Web.NavWebUISessionInitializer.Initialize(UISession session) i S:\Depot\Platform-Core\platform\client\web\Prod.Client.WebCommon\Session\NavWebUISessionInitializer.cs:linje 77
   ved Microsoft.Dynamics.Framework.UI.Client.OpenFormExecutionStrategy.TryInitializeUiSession(UISession session) i S:\Depot\Platform-Core\platform\client\Shared\Prod.ClientFwk\Client\Interactions\ExecutionStrategies\OpenFormExecutionStrategy.cs:linje 67
   ved Microsoft.Dynamics.Framework.UI.Web.WebOpenFormExecutionStrategy.TryInitializeUiSession(UISession session) i S:\Depot\Platform-Core\platform\client\web\Prod.Client.Web\Interactions\ExecutionStrategies\WebOpenFormExecutionStrategy.cs:linje 61
   ved Microsoft.Dynamics.Framework.UI.Client.OpenFormExecutionStrategy.Execute() i S:\Depot\Platform-Core\platform\client\Shared\Prod.ClientFwk\Client\Interactions\ExecutionStrategies\OpenFormExecutionStrategy.cs:linje 41
   ved Microsoft.Dynamics.Framework.UI.InteractionManager.<>c__DisplayClass8_2.b__4() i S:\Depot\Platform-Core\platform\client\Shared\Prod.ClientFwk\Interactions\InteractionManager.cs:linje 125
Source: Microsoft.Dynamics.Nav.Client.ServiceConnection
Error accessing Website 
Unhandled error occurred on a browser or device client:
{
  "clientInfo": {
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362",
    "browserLanguage": "da-DK"
  },
  "message": "Unable to get property 'getElementsByClassName' of undefined or null reference",
  "pageUrl": "https://xxxxxxxxxx/yyyyyyyyyy/?runinframe=1",
  "originalError": {},
  "location": {
    "name": "https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0",
    "url": "https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0",
    "lineNumber": 4562,
    "columnNumber": 58
  },
  "detailedMessage": "   at DN.LogicalFormAdapter.prototype.$105 (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:5188:1958)\r\n   at DN.LogicalFormAdapter.prototype.initializeNativeControl (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:5152:101)\r\n   at DN.LogicalControlAdapter.prototype.$27 (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:4839:1117)\r\n   at DN.LogicalControlAdapter.prototype.createContent (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:4833:6623)\r\n   at DN.LogicalControlAdapter.prototype.buildCore (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:4834:399)\r\n   at Type.prototype.callBaseMethod (https://xxxxxxxxxx/yyyyyyyyyy/js/mscorlib.js?h=D3729A20D7B95888CE98A4A7D3E48A9F0C340D80C5F72A67326464A956360F0E&_v=1.0.0:1:23528)\r\n   at DN.LogicalFormAdapter.prototype.buildCore (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:5160:156)\r\n   at DN.LogicalControlAdapter.prototype.build (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:4833:6709)\r\n   at DN.LogicalControlAdapter.prototype.buildChildAdapter (https://xxxxxxxxxx/yyyyyyyyyy/js/framework.js?h=69F05AE1092A2D30721123840E70FB027600B5F7A4BA9069BAE99A1E20C9168D&_v=1.0.0:4834:1581)\r\n",
  "requireUserToSignOut": false,
  "silent": true
}

Well – congratulations. You probably hit the same rabbit hole I just wasted 2 hours on.

Please go through you Role Center PageParts and check if you by mistake filled the InstructionalTextML property with something. I don’t want you to check the Role Center page, but check the individual PageParts pages. It is a global parameter on them.

If you did – remove it and this problem is magically gone :-)…

Note: This issue HAS off cause been reported to Microsoft (it got case ID 119071922000172 ). They have confirmed that it also seems to be present on Microsoft Dynamics 365 Business Central 2019 spring release.

I’ve discovered it in 2018 fall release CU7 (running single tenant and NavUserPassword authentication – not that I think that is part of the cause). I’ll expect it to be also present in at least 2018 fall release CU9 and 2019 spring release CU1.

Microsoft confirms they are looking into fixing it and a fix will be released in a future CU.

Publish-NAVApp : Extension compilation failed

Dynanmics 365 Business Central logo

Have you ever tried to publish an app-file using the Publish-NavApp PowerShell Cmdlets on a on-premises Microsoft Dynamics 365 Business Central and was stopped by errors like these:

Publish-NAVApp : Extension compilation failed
source/codeunits/Cod13653.PaymentExportManagement.al(4,27): error AL0185: Codeunit 'Payment Export Mgt' is missing
source/codeunits/Cod13656.DataMigration.al(15,28): error AL0185: Codeunit '9002' is missing
source/codeunits/Cod13650.FIKManagement.al(54,24): error AL0185: Table 'Payment Method' is missing
source/codeunits/Cod13650.FIKManagement.al(98,29): error AL0185: Table 'Company Information' is missing
source/codeunits/Cod13650.FIKManagement.al(126,59): error AL0185: Table 'Bank Acc. Reconciliation' is missing
source/codeunits/Cod13650.FIKManagement.al(128,18): error AL0185: Table 'Bank Account' is missing
source/codeunits/Cod13650.FIKManagement.al(129,22): error AL0185: Table 'Data Exch. Def' is missing
source/codeunits/Cod13650.FIKManagement.al(130,26): error AL0185: Table 'Data Exch. Mapping' is missing
[…]
source/codeunits/Cod13657.FIKSubscribers.al(360,46): error AL0132: 'Page' does not contain a definition for 'Payment Application'
 source/codeunits/Cod13657.FIKSubscribers.al(361,56): error AL0185: Page 'Payment Application' is missing
 source/codeunits/Cod13657.FIKSubscribers.al(361,111): error AL0185: Table 'Bank Acc. Reconciliation Line' is missing
 At line:10 char:1
 Publish-NAVApp -ServerInstance $ServerInstance -SkipVerification -Pat …
 ~~~~~~~~~~~~~~~~~ CategoryInfo          : InvalidOperation: (:) [Publish-NAVApp], InvalidOperationException
 FullyQualifiedErrorId : MicrosoftDynamicsNavServer$DynamicsNAV/nav-systemapplication,Microsoft.Dynamics.Nav.Apps.Management.Cmdlets.PublishNavApp 

Note – it seems that all objects are missing!?

It seems illogical, but it is fixed by running symbol generation:

  1. In the Microsoft Dynamics 365 Business Central administrative console you should set the parameter Enable loading application symbol references at server startup in the Development group.
  2. Then you should go to the Program Files (x86) installation folder for the Role Tailored Client (typically C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\<version>\RoleTailored Client) and run this command:
finsql.exe Command=generatesymbolreference, Database="<application sql database>", ServerName=<sql server host name>, ntauthentication=no, username=<sql server username>, password=<sql server password>

Note: The finsql.exe command will start a background finsql.exe process (you can see it in Windows Task Manaer). When it finishes it will write one or two text-files in the Role Tailored Client directory – one with status (filename navcommandresult.txt) and the other one if any errors happens (filename naverrorlog.txt).

These two steps fixed it for me.

You can read more about the symbol generation in the Microsoft documentation by clicking here!

Bad Request – Error in query syntax.

PowerShell logo

No, this is not an error in WordPress on this server – “Bad Request – Error in query syntax.” is in fact the intended subject for this Blog post :-).

If you are running OData WebServices towards you Microsoft Dynamics NAV or 365 Business Central (DBC) and you get this error – and you have a forward slash ( “/” ) in the company name in question, then this Blog post is for you :-).

You have just discovered that Excel, PowerShell.exe and/or older version of PowerShell ISE cannot work with OData URLs with a forward slash in the …/Company(‘<my company name>’)/… part of the URL.

A obvious solution is to rename the company in NAV/DBC – but that is not really a neat solution, is it?

According to this Microsoft blog post, another far superior solution exists. NAV/DBC supports two syntaxes when stating the company name.

The “classic” one you use for OData version 3 when you got the error:

https://<my hostname>:<my odata port>/<my instance>/OData/Company('<my company')/<my webservice>

…or the corresponding OData version 4 one:

https://<my hostname>:<my odata port>/<my instance>/ODataV4/Company('<my company')/<my webservice>

…and another one for working around this error:

https://<my hostname>:<my odata port>/<my instance>/OData/<my webservice>?company='<my company>'

…or the corresponding OData version 4 one:

https://<my hostname>:<my odata port>/<my instance>/ODataV4/<my webservice>?company='<my company>'

Note that you can off cause add additonal parameters (selecting tenant or setting filters etc.) to the URL using the ampersand sign ( “&” ) – just like you do when construction any URL.

Congratulations – you solved your problem 🙂

If you want to learn more about OData towards NAV/DBC, I suggest you visit these links:

Sendmail/smart host – this time with Microsoft Azure and SendGrid.com

FreeBSD logo

Hi,

As mentioned here, my internet service provider (ISP, Eniig) has announced that they will not provide a SMTP relay host (outgoing Simple Mail Transfer Protocol relay), and on top of that they earlier stated that they will not even setup reverse DNS on my fixed IP. They recommended smtp.dk and it has worked flawlessly since I configured it at described here!

Unfortunately (for them) smtp.dk seems to have raised their prices for their low quantity “Emails To Go”-subscription, and that makes one wonder if one can get it cheaper than DKK 0.02 per e-mail :-).

It seems that if you create a Microsoft Azure account (which is free as long as you don’t use services you need to pay for – well, in fact it is even cheaper than free – they give you some introduction credits you can test their paid services with 🙂 ), you can create a free SendGrid.com account with 25,000 free e-mails a month! (even if you need more, they are still way cheaper than smtp.dk).

Just like smtp.dk, SendGrid.com requires you to use the SMTP submit port (587) and authentication. But we already solved that for smtp.dk as described here, so that should not cause too much hassle :-).

I just did it like this:

1.
Add a API Key on SendGrid.com using menu “API Keys” after logging in.
Give it a good name so you know what it is for.
Optional: Create it with “Restricted access” and only grant it permission for “Mail Send” / “Mail Send”.
Make a note of the “API Key” as it will only be shown during creation (you cannot get it afterwards).

2.
Create /etc/mail/access with this contents (terminate it with a line break):

smtp.sendgrid.com       OK
GreetPause:localhost    0

3.
Create /etc/mail/authinfo with one line (terminate it with a line break):

AuthInfo:smtp.sendgrid.net "U:root" "I:apikey" "<You SendGrid API Key>" "M:LOGIN"

…replacing values in < > with the API Key you made a note of above.
Hint: You can leave other logins in here for safekeeping if you want to (like your smtp.dk details).
I feel most secure by making this file rw for root only

4.
Run makemap of the two fils to create access.db and authinfo.db-files:

makemap hash access < access
makemap hash authinfo < authinfo

5.
Correct your sendmail.mc-file (whatever it is called on your system). Add these lines:

define(`SMART_HOST',`[smtp.sendgrid.net]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`authinfo',`hash /etc/mail/authinfo')dnl

Note: You should change this for the sendmail queue runner process, not a SMTP submit service etc.

6.
Compile your sendmail.mc file into a sendmail.cf file. This is easily done on FreeBSD 🙂

make cf

7.
Restart sendmail. Again – this is easy on FreeBSD

make restart

Also: remember to correct your SPF and similar setups on your domains according to SendGrids documentation. You’ll find SendGrids SPF documentation here!

“External Azure Active Directory” users and Single-Sign-On in Dynamics 365 Business Central

Dynanmics 365 Business Central logo

If you are setting up Single-Sign-On (SSO) for Dynamics 365 Business Central (DBC) and you are only able to authenticate users local to the Azure Active Directory (i.e. non Guest or “External Azure Active Directory” users), then you might have stumbled across the same error as me.

The error manifests itself by allowing you to log in using SSO, but just when the DBC webclient is suppose to open, you get this error:

Your user name or password is incorrect, or you do not have a valid account in Dynamics 365 Business Central.

The problems is that a user with that authentication e-mails IS in fact present in DBC – so the error makes no sense.

Also you will sometimes get a warning in the Event Viewer that the SSO token was valid, but the user could not be found in DBC.

As mentioned the local domains works fine, it is only if you try to add external users and authenticate with those it does not work:

User type: Guest
Source: External Azure Active Directory

I’ve seen this error in Microsoft Dynamics 365 Business Central 2018 fall release with cumulative update 1 and 2.

I’m aware that you – with powershell – can change a User type Guest to a User type Member. I tried it, but the result was the exact same. So “no cigar” for that solution.

After upgrading the platform to the latest Cumulative Update (which is 7 while I’m writing this), the error is completely gone. So there you have your fix :-).

Note: I’ve not tested all the CUs between 2 and 7 to figure out when it was fixed or if there is a entry in the fix list that mentions this – so if you have more knowledge about that, please share by adding a comment.

Arduino IDE v1.8.9, esp32 v1.0.2 and ulptool v2.3.0

Arduino logo

Are you messing with ultra low power esp32 code and have tried to setup the ulptool example from duff2013s GitHub in Arduino IDE v1.8.9 with Espressif Systems esp32 v1.0.2?

Maybe you got a lot of strange compile errors like these?

Traceback (most recent call last):
 File "C:\Users\<your user name>\AppData\Local\Arduino15\packages\esp32\tools\ulptool\src/esp32ulp_build_recipe.py", line 506, in 
 main(sys.argv[1:])
 File "C:\Users\
<your user name>\AppData\Local\Arduino15\packages\esp32\tools\ulptool\src/esp32ulp_build_recipe.py", line 106, in main
 build_ulp(PATHS, ulp_files, board_options, True)
 File "C:\Users\
<your user name>\AppData\Local\Arduino15\packages\esp32\tools\ulptool\src/esp32ulp_build_recipe.py", line 136, in build_ulp
 proc = subprocess.Popen(cmd[1],stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
 File "C:\Python27\lib\subprocess.py", line 394, in init
 errread, errwrite)
 File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
 startupinfo)
 WindowsError: [Error 2] The system cannot find the file specified
 exit status 1
 Error compiling for board ESP32 Dev Module.

Note: This error is also reported here: https://github.com/duff2013/ulptool/issues/35

It is quite a simple fix: The error is probably caused by Espressif Systems moving around some files in esp32 v.1.0.2 – or actually renaming a catalog.

You just need to edit a single file in ulptool v2.3.0. Simply open your platform.local.txt file and change the line:

compiler.ulp.path={runtime.tools.ulptool.path}/esp32ulp-elf-binutils/bin/

…to…

compiler.ulp.path={runtime.tools.ulptool.path}/bin/

…and you are “back in business” :-).

DBC: “An error occurred while trying to display the report.”

Dynanmics 365 Business Central logo

If you get this error when you try to preview a report in Dynamics 365 Business Central:

An error occured while trying to display the report

An error occurred while trying to display the report.

…your firewall may be to restrictive.

A symptom of the same error is if you hit the Print button instead of the Preview button, and the preview during printer selection shows a “403 – Forbidden: Access is denied”-error.

We have seen this on Azure Firewall when it was set to “Prevention mode” instead of “Detection mode”. I guess one could whitelist the requests and keep “Prevention mode”, but how to do that is off cause Firewall dependent and outside the scope of this posts.

If you have a solution for your firewall, feel free to add it as a comment :-).