Zum Inhalt springen
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-Invoicing-Formate UBL, CII, ZUGFeRD und Factur-X im Vergleich

UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt

UBL, CII, ZUGFeRD oder Factur-X – diese E-Invoicing-Formate werden ständig verwechselt. Wir erklären den Unterschied zwischen reinen XML-Formaten und Hybridform

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
E-Invoicing formats UBL, CII, ZUGFeRD and Factur-X compared

UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained

UBL, CII, ZUGFeRD or Factur-X – these e-invoicing formats get confused all the time. We break down the difference between pure XML formats and hybrid PDF-plus-X

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained