If you have downloaded a language module to 2013 or 2013 R2 you will have a folder containing all the charts in that language.
The problem is that in standard Dynamics NAV you can only import them one by one plus that the function is real crappy!
But don’t worry, I’m going to give you the code to import all of them at the same time.
If you don’t have a language module but instead a cronus databas in another language and want to export all charts from that dabase see the blog post Dynamics NAV: Export All Charts
The principle behind this code is to filter out the files in the folder. For each file, upload it to the server, extract the ID and the name from the filename.
Create a new record, create a outstream to the file and instream to the blob in the record. Copy the outstream to the instream.
Here is the entire code in Dynamics NAV 2013 R2 text format. Copy and paste into a text file and import.
OBJECT Codeunit 93040 Import All Charts { OBJECT-PROPERTIES { Date=14-09-25; Time=23:02:44; Modified=Yes; Version List=NAVfreak.com; } PROPERTIES { OnRun=VAR Description@1000000001 : Text; ID@1000000000 : Code[20]; Name@1000000002 : Text; BEGIN IF NOT CONFIRM('Do you really want import all charts?',FALSE) THEN ERROR(''); ImportAllCharts('C:\temp\'); MESSAGE('Done'); END; } CODE { PROCEDURE ImportAllCharts@1000000001(Path@1000000000 : Text); VAR TempTempBlob@1000000011 : TEMPORARY Record 99008535; FileList@1000000001 : Record 2000000022; Chart@1000000004 : Record 2000000078; FileManagement@1000000006 : Codeunit 419; TempFile@1000000002 : File; NVInStream@1000000010 : InStream; Outstream@1000000009 : OutStream; Description@1000000008 : Text; FileName@1000000005 : Text; ToFile@1000000007 : Text[1024]; ID@1000000003 : Code[20]; BEGIN FileList.SETRANGE(Path,Path); FileList.SETRANGE("Is a file",TRUE); FileList.SETFILTER(Name,'@*.xml'); IF NOT FileList.FINDSET THEN ERROR('Did not find any files in folder %1',Path); REPEAT FileName := COPYSTR(FileList.Name,1,STRPOS(FileList.Name,' ')-1) + ',' + COPYSTR(FileList.Name,STRPOS(FileList.Name,' ')+1); //Unmark this if you use my chart exporting code ID := SELECTSTR(1,FileName); Description := SELECTSTR(2,FileName); Description := COPYSTR(Description,1,STRLEN(Description)-4); IF NOT Chart.GET(ID) THEN BEGIN FileName := FileManagement.UploadFileSilent(Path + '\' + FileList.Name); TempFile.OPEN(FileName); TempFile.CREATEINSTREAM(NVInStream); Chart.INIT; Chart.ID := ID; Chart.Name := Description; Chart.INSERT(TRUE); Chart.BLOB.CREATEOUTSTREAM(Outstream); COPYSTREAM(Outstream,NVInStream); Chart.MODIFY; TempFile.CLOSE; COMMIT; FileManagement.DeleteServerFile(FileName); END; UNTIL FileList.NEXT = 0; END; BEGIN { ************************** **** www.NAVFreak.com **** ************************** Blog Post: https://navfreak.com/2014/09/25/dynamics-nav-language-module-import-all-charts/ } END. } }
More information: How To Install Language Modules
One response to “Dynamics NAV Language Module: Import All Charts”