Skip to main content

Test Database for Object Languages

$DatabaseServer = "";
$DatabaseName = "";
$ApplicationObjectFilePath = ""; #Finish with \
$LanguageToTestFor = "ENU","DAN"; #Languages to search for seperate with , ex. "ENU","DAN"
$PathDynamicsNavManagement = ""; #Path for: Microsoft.Dynamics.Nav.Management.dll
$PathDynamicsNavModelTools = ""; #Path for: Microsoft.Dynamics.Nav.Model.Tools.psd1

#-------------------------------DO NOT EDIT UNDER THIS LINE-------------------------------
Import-Module $PathDynamicsNavManagement;
Import-Module $PathDynamicsNavModelTools -disablenamechecking;

$AllobjectsPath = $ApplicationObjectFilePath + "Objects\"

if (!(Test-Path $AllobjectsPath)) {
New-Item -ItemType directory -Path $AllobjectsPath
}

$FilePath = $ApplicationObjectFilePath + $DatabaseName + ".txt";
Export-NAVApplicationObject -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName -Path $FilePath -ExportTxtSkipUnlicensed -Force
Split-NAVApplicationObjectFile -Source $FilePath -Destination $AllobjectsPath

$Files = Get-ChildItem ($AllobjectsPath + "*.txt")
foreach ($file in $files) {
Test-NAVApplicationObjectLanguage -Source $file -LanguageId $LanguageToTestFor -ErrorAction SilentlyContinue -ErrorVariable LangError
if($LangError) {
"Missing caption in object: {0}" -f $file.BaseName
$LangError.Clear()
}
}