Hello !
Someone have an idea how to import an object (text) to Dynamics NAV 2013 by the code C/AL code
For information : the function IMPORTOBJECTS(filename) is not supported by NAV 2013
if (Test-Path "$LogFolder\navcommandresult.txt")
{
Write-Verbose "Processed $TextFile ."
Remove-Item "$LogFolder\navcommandresult.txt"
}
else
{
Write-Warning "Crashed when importing $TextFile !"
}
If (Test-Path "$LogFile") {Write-Warning "Error when importing $TextFile"}
}
}
# Welcome message
write-host $Command
write-host "`nWelcome to the Server Admin Tool Shell!"
write-host "For a complete list of Server cmdlets type`n"
write-host -fore Yellow "Get-Command *NAVServer*`n"
# Register Microsoft Dynamics NAV Management Snap-in
Import-NAVApplicationObjectFilesFromFolder "D:\fichiers" "D:\log" "Demo Database NAV (7-0)"
# Print available commands
Get-Command *NAVServer*
But I have this error in log file :
[22922070] The following SQL Server error or errors occurred: 18456,"28000",[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'Domaine\login'.
I tested and runned this command line ,and it's not work,I have an error message ([22922070] The following SQL Server error or errors occurred: 18456,"28000",[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'Domaine\user'.)
"C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\finsql.exe" command=importobjects ntauthentication=yes, servername=AMH-LAPTOP\NAVDEMO, database=Demo Database NAV (7-0), company=CRONUS France S.A. , file=D:\fichiers\T27.txt"
but if I test this : "C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\finsql.exe" ntauthentication=yes, servername=AMH-LAPTOP\NAVDEMO, database=Demo Database NAV (7-0), company=CRONUS France S.A.
My command line works very well
Someone have an idea why my first command don't work ??
Comments
this is only possible via command line parameters in NAV2013.
with best regards
Jens
I created this script ....and launched it by Microsoft Dynamics NAV 2013 Administration Shell
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Register Snap-in
function Import-NAVApplicationObjectFilesFromFolder
{
[CmdletBinding()]
param (
[String]$SourceFolder,
[String]$LogFolder,
[String]$Database,
[String]$UserName,
[String]$Pwd,
[String]$ServName
)
$UserName = 'Domaine\login'
$Pwd = 'mp'
$ServName = 'AMH-LAPTOP\NAVDEMO'
$NAVFolder = 'C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client'
$importfinsqlcommand = """$NAVFolder\finsql.exe"" command=importobjects,servername=$ServName,ntauthentication=0,username=$UserName,password=$Pwd,database=$Database,file="
$TextFiles = gci "$SourceFolder\*.txt"
foreach ($TextFile in $TextFiles){
$Command = $importfinsqlcommand + $TextFile
write-host $Command
$LogFile = "$LogFolder\$($TextFile.Basename).log"
if ($LogFolder -ne ""){$Command = $Command + ',LogFile=' + "$LogFile"}
Write-Debug $Command
cmd /c $Command
if (Test-Path "$LogFolder\navcommandresult.txt")
{
Write-Verbose "Processed $TextFile ."
Remove-Item "$LogFolder\navcommandresult.txt"
}
else
{
Write-Warning "Crashed when importing $TextFile !"
}
If (Test-Path "$LogFile") {Write-Warning "Error when importing $TextFile"}
}
}
# Welcome message
write-host $Command
write-host "`nWelcome to the Server Admin Tool Shell!"
write-host "For a complete list of Server cmdlets type`n"
write-host -fore Yellow "Get-Command *NAVServer*`n"
# Register Microsoft Dynamics NAV Management Snap-in
Import-NAVApplicationObjectFilesFromFolder "D:\fichiers" "D:\log" "Demo Database NAV (7-0)"
# Print available commands
Get-Command *NAVServer*
But I have this error in log file :
[22922070] The following SQL Server error or errors occurred: 18456,"28000",[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'Domaine\login'.
([22922070] The following SQL Server error or errors occurred: 18456,"28000",[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'Domaine\user'.)
"C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\finsql.exe" command=importobjects ntauthentication=yes, servername=AMH-LAPTOP\NAVDEMO, database=Demo Database NAV (7-0), company=CRONUS France S.A. , file=D:\fichiers\T27.txt"
but if I test this :
"C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\finsql.exe" ntauthentication=yes, servername=AMH-LAPTOP\NAVDEMO, database=Demo Database NAV (7-0), company=CRONUS France S.A.
My command line works very well
Someone have an idea why my first command don't work ??