Importing C/AL Text Objects via PowerShell

How-To Import Object Textfiles

Daniel Gorski
Daniel Gorski 10. Dezember 2021
2 Min. Lesezeit

If you want to import several objects based on a textfile, you should split them and run this PowerShell script:

Import-Module "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client\Microsoft.Dynamics.Nav.Ide.psm1"

Get-ChildItem $PSScriptRoot -Filter *.txt | Import-NAVApplicationObject -DatabaseName "Demo Database NAV (14-0)" -DatabaseServer SQL01 -NavServerInstance BC140 -NavServerManagementPort 7045

This two-liner will import all .txt files from your PowerShell script root folder into your database.


Example: Import Errors

Any importing errors will be shown separately.
This is the first entry in your log:

Import-NAVApplicationObject : : \[21364760\] Es gibt einen Syntaxfehler beim Import auf Zeile 219 , Position 16 : DecimalPlaces=0:5;.
Ein '{' (ElemBegin) wurde erwartet. -- File: C:\\page_0000000515.TXT
\[0\] Der Import brach ab bei Zeile 219. -- File: C:\\page_0000000515.TXT
In Zeile:1 Zeichen:81
- ... ter *.txt | Import-NAVApplicationObject -DatabaseName "Demo Database ...
-                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  - CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
  - FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Import-NAVApplicationObject

This is the second entry:

Import-NAVApplicationObject : : \[23462179\] Das Funktionsattribut \[AccSchedLine2\] ist in diesem Kontext ungültig. -- File: C:\\report_0000000029.TXT
\[0\] Der Import brach ab bei Zeile 390. -- File: C:\\report_0000000029.TXT
In Zeile:1 Zeichen:81
- ... ter *.txt | Import-NAVApplicationObject -DatabaseName "Demo Database ...
-                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  - CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
  - FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Import-NAVApplicationObject

Critical Error

If you see this error:

Interner Fehler '9' in Modul '24'. Internal Error '9' in Module '24'.

Then you should check your object for doubled triggers:

Fehlerquelle: doppelte Trigger

beyondit
how-to
NAV
C/AL
Import
PowerShell
Fehleranalyse
E-Invoice Viewer for Business Central

New Open-Source E-Invoice Viewer for Business Central

View and convert German XRechnung XML files directly in Microsoft Dynamics 365 Business Central with the new open-source E-Invoice Viewer from BEYONDIT.

Weiter lesen
Weiter lesen
E-Invoice Viewer für Business Central

Neue Open-Source-App: E-Invoice Viewer für Business Central

Lesen und konvertieren Sie deutsche XRechnung-XML-Dateien direkt in Microsoft Dynamics 365 Business Central mit dem neuen Open-Source E-Invoice Viewer von BEYON

Weiter lesen
Weiter lesen