In Dynamics NAV reports we use SetData and GetData functions to retrieve data certain data in page headers and footers due to different scopes. In this blog post I’m not going to explain why and how but I’m going to give links to some good posts that does it at the bottom this post. Instead I’m going to give you a tip on how to make the process of adding/finding which data that has a certain index in the SetData function call by using line numbers.
Tag Archives: NAV
Dynamics NAV 2009 R2: DotNet System.String
If you are having the need to use DotNet in an older client such as Dynamics NAV 2009 R2 you will problably run into troubles which they have fixed for later versions of Dynamics NAV. I had the problem that I tried to downgrade code using the DotNet type System.String. I didn’t get very far until the compiler started to complain…
XMLPort: Import Into Temporary Table
Earlier today I wrote a blog post XMLPort: Export from temporary tables. The principle is the same when you want to import to a temporary table. Instead of calling a function in XMLPort before you call the export that inserts values into the temporary table you do the opposite, call a function after the import has completed that copies all the temporary data to your temporary record parameter. Read the rest of this entry »
XMLPort: Export from temporary tables
You can export data from tables to XML by using XMLPorts. But you can also use XMLPorts to export data from temporary tables.
The principle is to set the Temporary property on the table line and then create a function in XMLPort that inserts all the data into the temporary record.
Dynamics NAV Charts: Export All Charts
You have probably ended up here because you want to export all charts but the standard NAV functionality only lets you export them one by one ( Generic Charts on msdn). Maybe you currently are upgrading a customer database from a pre Dynamics NAV RTC version and now you want to add the charts to the current database. Or you have a database with a different language base and want to export/import the charts from another database with a different language. Anyway, see code below.
I have created a codeunit that exports all charts by iterating trough all charts, checking if the current record has a blob value. If it has a value create a stream that streams the data to a local temp file on the server, then download the file from server to the specified folder on the client. Finally, delete the server file.
Here you can find the entire code in 2013 R2 format. Just copy and paste into a text file. Save and import.
Beware, you need a developer license to import the object and after that you need to make sure or rename so the object is within the customer’s license.
Once done you will probably want to import all the charts to the target database. Here you can read about importing all Dynamics NAV charts.
OBJECT Codeunit 93041 Export All Charts { OBJECT-PROPERTIES { Date=14-09-25; Time=19:11:46; Version List=NAVfreak.com; } PROPERTIES { OnRun=BEGIN IF NOT CONFIRM('Do you really want export all charts?',FALSE) THEN ERROR(''); ExportAllCharts('C:\@tmp\diagram\'); MESSAGE('Done'); END; } CODE { PROCEDURE ExportAllCharts@4(Path@1000000002 : Text) : Text; VAR TempTempBlob@1000000001 : TEMPORARY Record 99008535; Chart@1000000000 : Record 2000000078; FileManagement@1000000006 : Codeunit 419; TempFile@1000000003 : File; NVInStream@1003 : InStream; Outstream@1000000004 : OutStream; FileName@1000000005 : Text; ToFile@1004 : Text; IsDownloaded@1007 : Boolean; BEGIN //Precondition: Path needs to end with a \ IF NOT Chart.FINDSET THEN EXIT; REPEAT Chart.CALCFIELDS(BLOB); IF Chart.BLOB.HASVALUE THEN BEGIN TempTempBlob.Blob := Chart.BLOB; TempTempBlob.Blob.CREATEINSTREAM(NVInStream); FileName := FileManagement.ServerTempFileName('xml'); TempFile.CREATE(FileName); TempFile.CREATEOUTSTREAM(Outstream); COPYSTREAM(Outstream,NVInStream); TempFile.CLOSE; ToFile := Path + Chart.ID +',' + Chart.Name + '.xml'; FileManagement.DownloadToFile(FileName,ToFile); FileManagement.DeleteServerFile(FileName); END; UNTIL Chart.NEXT = 0; END; BEGIN { ************************** **** www.NAVFreak.com **** ************************** Blog Post: https://navfreak.com/2014/09/25/dynamics-nav-charts-export-all-charts/ } END. } }