STAEDEAN Business Central Documentation

Initialize IEM

When deployed on premises a new database must be created, "build-up" with the Microsoft System Application and completed by the IEM Application.

The process starts with completing an installation of the set as obtained from the Download Microsoft Business Central On-Premises site. Once the installation is completed and you have access through a modern client to the CRONUS demo company follow these steps (you can copy and paste the code to ISE):

NOTES 1

  • The CreateDatabase.ps1 script assumes that the AL Development Environment is installed from the Dynamics 365 Business Central DVD. Copy the path to the $systemApp variable. The $systemApplication variable must point to the path from where the Setup was run.
  • The CreateDatabase.ps1 script assumes a SQL server without instances, make sure when specifying the installation options in the Dynamics 365 Business Central setup the database instance is left blank.
  • From your desktop run Windows PowerShell ISE as administrator.

CreateDatabase.ps1

# Import the NAV Management modules in ISE (make sure to select the correct version of the program files folder):
Import-Module "C:\Program Files\Microsoft Dynamics 365 Business Central\200\Service\Microsoft.Dynamics.Nav.Apps.Management.psd1"  
Import-Module "C:\Program Files\Microsoft Dynamics 365 Business Central\200\Service\Microsoft.Dynamics.Nav.Management.psd1"  

# Define the variables for the script (current values are provided as examples):  
$serverInstance = 'BC200'  
$databaseName = "ToIncrease"  
$databaseServer = "localhost"  
$applicationVersion = '20.1.39764.39901'  
$applicationFamily = 'W1'  
$systemApp = "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\200\AL Development Environment\System.app"  
$systemApplication = "C:\ ... \Applications\System Application\Source\Microsoft_System Application.app"  
$companyName = 'IEM'  

# Create a new database:  
New-NAVApplicationDatabase -DatabaseName $databaseName  -DatabaseServer $databaseServer  
Set-NAVServerConfiguration -KeyName DatabaseName -KeyValue $databaseName -ServerInstance $serverInstance  
Restart-NAVServerInstance -ServerInstance $serverInstance  

# Connect the new database to the Business Central service:  
Set-NAVApplication -ApplicationVersion $applicationVersion -ServerInstance $serverInstance -Force  
Set-NAVApplication -ApplicationFamily $applicationFamily -ServerInstance $serverInstance -Force  
Sync-NAVTenant -ServerInstance $serverInstance -Mode Sync  

# Publish the Microsoft system application in the database:  
Publish-NAVApp -Path $systemApp -ServerInstance $serverInstance -PackageType SymbolsOnly  
Publish-NAVApp -Path $systemApplication -ServerInstance $serverInstance  
Sync-NAVApp -Name "System Application" -ServerInstance $serverInstance  

# Install the Microsoft system application in the database and create a new Company:  
Install-NAVApp -Path $systemApplication -ServerInstance $serverInstance  
New-NAVCompany -CompanyName $companyName -ServerInstance $serverInstance -CompanyDisplayName $companyName  

InstallIEMapps.ps1

To prepare for this script you need to download the STAEDEAN IEM Artifacts and unzip the downloaded folder on your desktop. Make sure to update your local path in the script (\ ... )

NOTES 2

Upon succesful completion of the 'CreateDatabase.ps1' script Extension Management will list the published and installed the extensions. The System Application shows the Dynamics 365 Business Central build number, while the STAEDEAN applications show the STAEDEAN build number. Example: 15.2.38860.0

  • 15 is the Business Central major version, must be the same between Microsoft and STAEDEAN.
  • 2 is the Business Central minor version (update), must be the same between Microsoft and STAEDEAN.
  • 38860 is the build number, will be different between Microsoft and STAEDEAN.
# When running this script in a seperate session in ISE we need to import the modules again
Import-Module "C:\Program Files\Microsoft Dynamics 365 Business Central\200\Service\Microsoft.Dynamics.Nav.Apps.Management.psd1"
Import-Module "C:\Program Files\Microsoft Dynamics 365 Business Central\200\Service\Microsoft.Dynamics.Nav.Management.psd1"
    
#apps in correct order up and until BC 20
$apps = "_Exclude_TI-Common,IEM Application,Application,_Exclude_TI-Lifecycle Base,IEM Lifecycle,IEM Extended Application,IEM Advanced Application"
#apps in correct order from BC 20.1
$apps = "IEM Application,Application,TI-Common,IEM Extended Application,IEM Advanced Application,TI-Lifecycle Base,IEM Lifecycle"
#When not upgrading all apps you can modify this list accordingly.

$serverInstance = 'BC200'

#Make sure to download and unzip the artifacts folder to the location where you are installing from.
$buildArtifactFolder = "C:\...\Artefacts\20.1.73246.0"
$appsSplit = $apps.Split(',')
$i = $appsSplit.Count

#Skip this section on an initial installation, only required when upgrading from a previous BCxx build.
Do{
    $i--
  Write-Host "Uninstall & Unpublish $($appsSplit[$i])"

  $installedAppVersion = Get-NAVAppInfo -ServerInstance $serverInstance|Where-Object { $_.Name -eq $appsSplit[$i] }|%{"$($_.Version.Major).$($_.Version.Minor).$($_.Version.Build).$($_.Version.Revision)"}
  Uninstall-NAVApp -Name $appsSplit[$i] -ServerInstance $serverInstance -Version $installedAppVersion
  Unpublish-NAVApp -Name $appsSplit[$i] -ServerInstance $serverInstance -Version $installedAppVersion 
}
Until($i -eq 0)


#Publish and Install apps
$apps.Split(',') | ForEach-Object {
    $appName = $_
    $AllAppFiles = Get-ChildItem -Path $buildArtifactFolder -Filter "*.app" -Recurse
    foreach ($AllAppFile in $AllAppFiles) {if ((Get-NAVAppInfo -Path $AllAppFile.FullName |Select-Object -expand Name) -eq $appName){$appFileName = $AllAppFile.FullName} }
    Write-Host "Install $_ ($appFileName)"
    $newAppVersion = Get-NAVAppInfo -Path $appFileName|%{"$($_.Version.Major).$($_.Version.Minor).$($_.Version.Build).$($_.Version.Revision)"}

    Publish-NAVApp -Path $appFileName -ServerInstance $serverInstance
    Sync-NAVApp -Name $appName -ServerInstance $serverInstance -Version $newAppVersion
    #Comment-out the next line on an initial installation, only required when upgrading from a previous BCxx build.
    Start-NAVAppDataUpgrade -Name $appName -ServerInstance $serverInstance -Version $newAppVersion
    Install-NAVApp -Name $appName -ServerInstance $serverInstance -Version $newAppVersion
}

STAEDEAN Common Documentation