RSS

Monthly Archives: September 2014

Dynamics NAV Language Module: Import All Charts

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 charts in the language module

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

 
1 Comment

Posted by on 2014-09-25 in Okategoriserade

 

Tags: , , , , ,

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.

Export_Generic_Charts

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.
 }
}
 
1 Comment

Posted by on 2014-09-25 in Okategoriserade

 

Tags: , ,

Set up backups in Azure part 4 – Notifications

Ok, so now we have our backups, Windows Server Backup, Azure Backup and SQL backup. If you have used a normal SQL edition and not express you have probably used maintenance plans to notify when the jobs fail but if you use SQL express you need to do it in another way and that is what I’m going to show you. Read the rest of this entry »

 
Leave a comment

Posted by on 2014-09-23 in Okategoriserade

 

Tags: , , , , ,

Set up backups in Azure part 3 – Windows Server Backup & Azure Backup

Welcome to my third post about Setting up backups in Azure. This post will be about Windows Server Backup and Azure backup.
Read the rest of this entry »

 
Leave a comment

Posted by on 2014-09-10 in Okategoriserade

 

Tags: , ,

Set up backups in Azure part 2 – SQL Backup

Time for the part two in this series which is going to be about SQL backups on a virtual machine in Azure. Read the rest of this entry »

 
1 Comment

Posted by on 2014-09-08 in Okategoriserade

 

Tags: , , ,

Get your own SMTP server!

Many times when we are coding email functions in Dynamics NAV and using Codeunit 400 SMTP Mail we need to fill in a SMTP adress in the setup.

NAVMail

This is here where the hassle starts. You need to contact the customers hosting partner so they can fix/open up a SMTP account for you and of course you will get questions like why and when you need it and if it is really necesary. On top of that you also got their leadtime of answering emails. Instead you ask your companys exchange administrator and he says forget it!

I say screw them! Lets get our own SMTP server.

Now you problaby imagine something like downloading software and installing SMTP server software somewhere at the customer premises without being noticed. Nah, that is not the solution I had in mind 🙂

Instead get an account at http://sendgrid.com/ . This is a cloud based service that is used to seend thousands of marketing emails and then see statistics who read what. But! They also offer a SMTP server which you at the moment can send 200 emails a day for free!! 

It takes 5-10 minutes before you get all the information you need but after that you don’t need to ask or wait for anyone to get you this type of information.

And another thing! This is excellent when you want to send notification emails from Azure, failed backups and so on.

Even noticed that Azure got a specific sendgrid plugin. Have to check it out later. Look at it here.

 
2 Comments

Posted by on 2014-09-08 in Okategoriserade

 

Tags: ,

Set up backups in Azure part 1 – Strategies

Many partners only specializes in Dynamics NAV and not in hosting. Often the customers have their own servers and are responsible for backups or a partner is responsible for the hosting environment.

What I’m trying to say is that probably many NAV partners haven’t been responsible for SQL backups before and now with putting everything in Azure we are skipping the hosting partner and instead becoming our own hosting partner.

When we do this we need to have a strategy to tackle this new scenario with this blog post  and following I would like to share some information from the field on how you can implement different backup strategies.

There are several ways to cover this and I’m going to mention the most obvious ones:

  1. SQL Backup
  2. Windows Server Backup
  3. Azure Backup
  4. System Center – Data Protection Manager

Read the rest of this entry »

 
Leave a comment

Posted by on 2014-09-07 in Okategoriserade

 

Tags: , ,

 
Mark Brummel Blog | Microsoft Dynamics NAV

Master Classes Design Patterns and more...

Vjeko.com

ideas in the cloud

Goprowe AB

Reflections from the ERP field

ArcherPoint Developer Blog

Reflections from the ERP field

The NAV Viking´s Blog

- Sharing my experience in the Dynamics NAV world

Comments for waldo's blog

Reflections from the ERP field

Nav Can Be Fun

Its Really Fun to Work with Microsoft Dynamics Nav

Navision-Girl.Com

Reflections from the ERP field

LET'S TALK NAV

Tips, Tricks, How-To's & News about Microsoft Dynamics NAV & Dynamics 365 for Financials

Kine's Info

Reflections from the ERP field

blog.wibeck.org/

Just another WordPress.com site

NAV/SQL Performance - My Two Cents

Reflections from the ERP field

Hougaard.com – Applied Hacking

Reflections from the ERP field

Kauffmann @ Dynamics NAV

Reflections from the ERP field

Kriki’s Dynamics NAV blog

Reflections from the ERP field

Rashed Amini

Reflections from the ERP field

Olof Simren - Microsoft Dynamics NAV Blog

My blog about Microsoft Dynamic NAV tips and tricks. Remember to Subscribe!

Van Vugt's dynamiXs

Reflections from the ERP field

Navisionary – Dynamics NAV

Reflections from the ERP field