Icelandic Localization

In the localized version of Dynamics NAV 2009 R2 the report layout for Role Tailored Client is missing.  I have created the layout and applied a few fixes to the reports.

ID Name Caption
204 Sales – Quote Sala – Tilboð
205 Order Confirmation Pöntunarstaðfesting
206 Sales – Invoice Sala – Reikningur
207 Sales – Credit Memo Sala – Kreditreikningur
210 Blanket Sales Order Standandi sölupöntun
405 Order Pöntun
406 Purchase – Invoice Innkaup – Reikningur
407 Purchase – Credit Memo Innkaup – Kreditreikningur
10911 IRS Details Upplýs. vegna skattstofu
10912 Trial Balance – IRS Number Prófjöfnuður – Skattst.númer
10913 IRS notification Tilkynning skattayfirvalda
10940 VAT Balancing A VSK-afstemming A
10941 VAT Balancing Report VSK

The following ZIP file is encrypted.

NAV IS2009R2 Reports

File download with RTC

My earlier post on File Download used the responsestream property of WinHTTP. On my latest project I needed to use Windows Authentication on my website and found out that I needed to create the WinHTTP automation on client level to login with the current user. This also means that I cannot use built in streaming functions to download the file. Instead I used ADOStream function to download the file and in the example that follows I am saving the file to the temporary directory for the current user.
[code htmlscript=”false”]DownloadFile(URL : Text[1024]) FileName : Text[1024]
IF ISCLEAR(WinHTTP) THEN
CREATE(WinHTTP,TRUE,TRUE);

WinHTTP.open(‘GET’,URL,FALSE);
WinHTTP.send(”);

IF WinHTTP.status <> 200 THEN
ERROR(Text023,WinHTTP.status,WinHTTP.statusText);

FileName := WinHTTP.getResponseHeader(‘Content-Disposition’);
IF STRPOS(FileName,’filename=’) = 0 THEN
FileName := ”
ELSE BEGIN
FileName := COPYSTR(FileName,STRPOS(FileName,’filename=’) + 10);
IF ISCLEAR(ADOStream) THEN
CREATE(ADOStream,TRUE,TRUE);

IF ADOStream.State = 1 THEN
ADOStream.Close;

ADOStream.Type := 1; // adVarBinary
ADOStream.Open;
ADOStream.Write(WinHTTP.responseBody);

IF ISCLEAR(FileSystem) THEN
CREATE(FileSystem,TRUE,TRUE);

FileFolder := FileSystem.GetSpecialFolder(2);
FilePath := FileFolder.Path;
ADOStream.SaveToFile(FilePath + ‘\’ + FileName,2);
FileName := FilePath + ‘\’ + FileName;

ADOStream.Close;
END;

CLEAR(WinHTTP);[/code]
Where my variables are

FileSystem – Automation – ‘Windows Script Host Object Model’.FileSystemObject
FileFolder – Automation – ‘Windows Script Host Object Model’.Folder
WinHTTP – Automation – ‘Microsoft XML, v6.0’.XMLHTTP
ADOStream – Automation – ‘Microsoft ActiveX Data Objects 2.8 Library’.Stream
FilePath – Text[1024]

Record Links and Attachments

The standard Record Links table in Dynamics NAV has the ability to store a URL and link it to any record in the Dynamics NAV database.  However, in order to fully use this each user must have access to the give URL.

As a part of the Purchase Invoice signing solution I built a process to select or scan a file, upload it to a SQL database and create a URL to that file in the Record Link table.  I create a  SQL link table that stores the file and a permission table that holds information on users permission by table id.

I used TwainControlX to scan and create files to import and link.  Then I add a “Link File” button to the Purchase Order.

When Link File is selected the following dialogue appears.

After selecting or scanning a file a new link is created and the file is uploaded to the SQL server.

The file is now available to all users that have the required permission through the following link.

The can be downloaded directly with the Open button or NAV can download and open the file with code.  I created a .ASP web page to download files from the Link database.

Printer Selection by Location Code

I recently was asked to redirect a invoice printout to different printers depending on a code variable on the sales invoice header.  The solution was created and I would like to share it with the example of using printers by location.

After installing this solution you will be able to select a invoice printer for each location.  If non is selected then the default printer from Printer Selection table will be used according to standard Dynamics NAV functionality.

PrinterByLocationCode

SMS from NAV

In modern ERP solutions the system should be able to send SMS to employees, customers and vendors.  The phone service provider Síminn in Iceland offers a web service interface for applications to send SMS.

Attached is a source code that uses this web service to send SMS.

SMS Source Code

Blob and RTC Client

I am working on a RTC interface for my Payroll System.  To my suprice some of the codes that are running perfectly on Classic Client do not work on the RTC Client.  One example is the code
[code htmlscript=”false”]DeleteOutgoingMessage(VAR Statement : Record "Payroll Statement")
WITH Statement DO BEGIN
TESTFIELD(Status,Status::Created);
CLEAR("Outgoing Message");
MODIFY;
END;[/code]
that worked in the Classic Client but needed to be
[code htmlscript=”false”]DeleteOutgoingMessage(VAR Statement : Record "Payroll Statement")
WITH Statement DO BEGIN
TESTFIELD(Status,Status::Created);
CALCFIELDS("Outgoing Message");
CLEAR("Outgoing Message");
MODIFY;
END;[/code]
to work in both clients.

Host Name

In Dynamics NAV applications I sometimes use the client host name to store settings or as a filter.  Until now I have been using the ENVIRON function but it is not available in NAV 2009.

I have now solved this issue with the following function that will also work in Role Tailored Client.
[code]IF ISCLEAR(WShell) THEN
CREATE(WShell,TRUE,TRUE);
EnviormentPath := ‘PROCESS’;
WEnviroment := WShell.Environment(EnviormentPath);
IF UPPERCASE(WEnviroment.Item(‘SESSIONNAME’)) = ‘CONSOLE’ THEN
ComputerName := WEnviroment.Item(‘COMPUTERNAME’)
ELSE
ComputerName := WEnviroment.Item(‘CLIENTNAME’)[/code]
Where

Name DataType Subtype
WShell Automation ‘Windows Script Host Object Model’.WshShell
WEnviroment Automation ‘Windows Script Host Object Model’.WshEnvironment
EnviormentPath Code[10]

Unzip Files

By using the Automation “‘Microsoft Shell Controls And Automation’.Shell” you can unzip a file within Dynamics NAV.

Create a Global

Name DataType Subtype
SystemShellControl Automation ‘Microsoft Shell Controls And Automation’.Shell
SystemShellItem Automation ‘Microsoft Shell Controls And Automation’.FolderItem
SystemShellItems Automation ‘Microsoft Shell Controls And Automation’.FolderItems
FileName Text
ZipFileName Text
DestFolderName Text
Index Integer
Pos Integer

And then simply
[code]ZipFileName := ‘C:\TEMP\ZipFile.Zip’;
DestFolderName := ‘C:\TEMP\’;
SystemShellItems := SystemShellControl.NameSpace(ZipFileName).Items;
SystemShellControl.NameSpace(DestFolderName).CopyHere(SystemShellItems);
FOR Index := 1 TO SystemShellItems.Count DO BEGIN
SystemShellItem := SystemShellItems.Item(Index – 1);
IF ISSERVICETIER THEN
FileName := SystemShellItem.Path
ELSE
FOR Pos := 1 TO STRLEN(SystemShellItem.Path) DO
IF COPYSTR(SystemShellItem.Path,Pos,1) = ‘\’ THEN
FileName := COPYSTR(SystemShellItem.Path,Pos + 1);
// Do what ever you whant to DestFolderName + FileName
END;[/code]

Download a File

In Dynamic NAV it is possible to use the Automation “‘Microsoft XML, v6.0’.XMLHTTP” to download files.  The code would be
[code]IF ISCLEAR(WinHTTP) THEN
CREATE(WinHTTP,TRUE,FALSE);

WinHTTP.open(‘GET’,URL,FALSE);
WinHTTP.send(”);

IF WinHTTP.status <> 200 THEN
ERROR(Text003,WinHTTP.status,WinHTTP.statusText);

TempFile.CREATE(TempFileName);
TempFile.CREATEOUTSTREAM(OutStr);
InStr := WinHTTP.responseStream;
COPYSTREAM(OutStr,InStr);
TempFile.CLOSE;[/code]
Where Text003 is “Status error %1 %2”

The URL will be downloaded to the filename “TempFileName”