21. Dezember 2017 13:55
ID=..49999;"Version List=*XYZ*"
Type=Page|Codeunit|Report;ID=55555..55666;"Name=*SEPA*";"Version List=*XYZ*"
[string]$MyEnviron = [Environment]::OSversion.Version.ToString(3) ; [bool]$OldEnviron = ($MyEnviron.substring(0,3) -eq '6.1')
function Export-NAV2ALfile
{
[CmdletBinding()]param (
[String]$WorkingFolder,
[String]$ExportFile,
[String]$Server,
[String]$Database,
[String]$Filter )
$LogFile = "$WorkingFolder\Log_$ExportFile"
$ExportFile = "$WorkingFolder\$ExportFile"
if (Test-path "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central" -PathType Container)
{$NAVide = Import-Module "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1"}
else
{$NAVide = Import-Module "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1" -WarningAction SilentlyContinue | out-null}
if (Test-Path "$WorkingFolder\navcommandresult.txt") {Remove-Item "$WorkingFolder\navcommandresult.txt"}
if (test-path $ExportFile) {remove-item $ExportFile}
if (Test-path "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central" -PathType Container) {$NAVFolder = "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client"}
else
{$NAVFolder = "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client"}
$exportfinsqlcommand = """$NAVFolder\finsql.exe"" command=ExportToNewSyntax,file=$ExportFile,servername=$Server,database=$Database,Logfile=$LogFile"
if ($Filter -ne "") {$exportfinsqlcommand = "$exportfinsqlcommand,filter=$Filter"}
$Command = $exportfinsqlcommand
Write-Host -ForegroundColor Green 'Export Objects with:'
Write-host -ForegroundColor Gray " $Command"
cmd /c $Command
$ExportFileExists = Test-Path "$ExportFile"
If (-not $ExportFileExists)
{
write-error "Error on exporting to $ExportFile. Look at the information below."
if (Test-Path "$WorkingFolder\navcommandresult.txt"){Get-Content "$WorkingFolder\navcommandresult.txt"}
if (Test-Path $LogFile) {Get-Content $LogFile}
break
}
else
{
$NAVObjectFile = Get-ChildItem $ExportFile
if ($NAVObjectFile.Length -eq 0) {Remove-Item $NAVObjectFile}
if (Test-Path "$WorkingFolder\navcommandresult.txt") {Get-Content "$WorkingFolder\navcommandresult.txt"}
}
$SplitDir = "$WorkingFolder\Split"
Write-Host "Splitting objects to $SplitDir"
Split-NAVApplicationObjectFile -Source $ExportFile -Destination $SplitDir -force
$Convertcommand = """$NAVFolder\txt2al.exe"" --source=""$WorkingFolder\Split"" --target=""$WorkingFolder\AL"" --rename"
$Command = $Convertcommand
Write-Host -ForegroundColor Green 'Convert objects with:'
Write-host -ForegroundColor Gray " $Command"
cmd /c $Command
}
Export-NAV2ALfile -WorkingFolder C:\MyWorkingFolder -ExportFile MyNAVObjects.txt -Server MyServer -Database MyDatabase -Filter "Version List=*MyAddOn*"
2. Oktober 2018 10:25
if (Test-path "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central" -PathType Container)
{$NAVide = Import-Module "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1"}
else
{$NAVide = Import-Module "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1" -WarningAction SilentlyContinue | out-null}
if (Test-path "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central" -PathType Container) {$NAVFolder = "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client"}
else
{$NAVFolder = "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client"}